Does not handle relative paths like http://bla.com/bla/2/3/../../bla.html #624

Closed
cbeley opened this Issue Aug 12, 2013 · 3 comments

2 participants

@cbeley

Title says it all. It would be nice if request normalized the urls before attempting to download them.

For the time being, I'm making use of URI.js's normalizePathname feature for anyone looking for a solution to this (apart from hacking something custom together).

@mikeal
request member

there is code to handle this, can you post some code that isn't working so we can track down the bug.

@cbeley

Sure thing. The following does not work:

EDIT: I should clarify, that by not work, you get a 404.

request("http://www.google.com/images/srpr/bla/2/yeah/../../../logo4w.png", function (error, response, body) {
if (!error && response.statusCode === 200) {
cb(null, body);
}
else {
if (error) {
cb(error);
}
else {
cb(new Error("Got Status Code: " + response.statusCode + " when retrieving " + fullFilePath));
}
}
});

If you replace the url with http://www.google.com/images/srpr/logo4w.png, it does work. Pretty much any variation of the above pattern does not work. Using something like URI.js's normalizePathname feature before passing the URL in gives the expected behavior.

@mikeal
request member

Is this still an issue?

This is so old I'm closing, if it is actually still an issue just let me know and I'll re-open.

@mikeal mikeal closed this Aug 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment