The Windows to Linux port tripped me up again, and this is an embarrassing one because I have written about just this issue, and apparently ignored my own advice. Nothing major, in fact it went unnoticed for several months (as this is on the first site that I ported), but a gotcha nonetheless.
http://www.cffaq.com/ has a breadcrumb navigation element at the top of the page. I noticed this morning that no matter what page I was on, the breadcrumb only contained a “home” option (the default used if the breadcrumb creation code is unable to work out where in the site we are). The problem? I was using code that read CGI.PATH_TRANSLATED to determine the URL being processed. CGI.PATH_TRANSLATED is a path, and I was treating it as a list delimited by (and then doing a ListLast() to get just the file name portion of the path). The problem? Unix uses / (slash) and not (backslash), and so the entire CGI.PATH_TRANSLATED was being returned by ListLast() and that broke things.
Truth is, / would not have worked on Windows (just as does not on Linux), any solution to pathing problems really needs to be dynamic. One option might be to initialize variables on startup (perhaps based on SERVER.os.name) with the right values. Another option might be to use a UDF that took a path and returned it in some normalized format. There is no single right solution to this one, as long as you are cognizant of the problem and actually implement a solution.
Leave a Reply