garycourt / uri-js

An RFC 3986 compliant, scheme extendable URI parsing/validating/normalizing/resolving library for JavaScript
Other
305 stars 69 forks source link

Fails to resolve some URI's that contains \r #18

Closed sondrele closed 7 years ago

sondrele commented 7 years ago

Hello!

I've tried replacing the built in url node module with uri-js because of the need to support more than just URL's.

However, I'm running into a problem when it comes to URI's that contains \r, consider the following example:

Code:

let url = require("url")
console.log(url.resolve("#", "#foo\nbar"))
console.log(url.resolve("#", "#foo\rbar"))

let URI = require("uri-js@2.1.1")
console.log(URI.resolve("#", "#foo\nbar"))
console.log(URI.resolve("#", "#foo\rbar"))

Output:

"#foo%0Abar"
"#foo%0Dbar"
"#foo%0Abar"
"#foo" 

I had expected uri-js to behave similar as url in the code above, but instead \rbar seems to be excluded when uri-js tries to resolve it.

There's also some other behaviour here, because the following code works:

console.log(URI.resolve("#", "foo\rbar")) // === "foo%0Dbar"

Do you know what the problem might be?

Thanks

garycourt commented 7 years ago

Fixed and closed by #20.