GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
connect 2.3.5 and 2.3.8
An example link:
<a href="%5Cexamples" class="" title="examples">examples</a>
where %5C is a the URL-encoding for \
Interestingly, URLs of this sort cause those links to be broken on Firefox, but not on Chrome. I suspect Chrome is being more liberal, and Firefox more strict in standards compliance, but I haven't verified this.
https://github.com/senchalabs/connect/blob/master/lib/middleware/directory.js#L175 is the location of the bug. path.join is being used, and it normalizes to the local machine's filesystem conventions, so any / characters in the dir argument are converted to \
The fix is to replace
dir + file
@jbuck points out that a fix that would preserve the existing semantics (the fact that join calls normalize to resolve stuff like "..") could be preserved more precisely by leaving the join in place and then using a regex to transliterate \ to /. This doesn't quite feel right to me, but maybe it is. My gut is that something like a normalizeURLPath function would be cleaner. Does one of the maintainers have an opinion on this, or an alternate suggestion?
my bad yeah we should just concat them
Is there any progress on this bug? I've just experienced the same problem and it makes the directory middleware quite unusable.
The generated URLs (those with backslashes) may work in some browsers, but that is not relevant. Only forward slashes can be used to define hierarchy in URLs.