Last active
October 4, 2016 08:19
-
-
Save rolinh/ba39c45b718cbd44f5f91af69b588c83 to your computer and use it in GitHub Desktop.
nodejs url.resolve() bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> var url = require("url"); | |
undefined | |
> var u = url.parse("https://foo.tld"); | |
undefined | |
> u | |
Url { | |
protocol: 'https:', | |
slashes: true, | |
auth: null, | |
host: 'foo.tld', | |
port: null, | |
hostname: 'foo.tld', | |
hash: null, | |
search: null, | |
query: null, | |
pathname: '/', | |
path: '/', | |
href: 'https://foo.tld/' } | |
> var v = url.parse("wss://foo.tld"); | |
undefined | |
> v | |
Url { | |
protocol: 'wss:', | |
slashes: true, | |
auth: null, | |
host: 'foo.tld', | |
port: null, | |
hostname: 'foo.tld', | |
hash: null, | |
search: null, | |
query: null, | |
pathname: null, | |
path: null, | |
href: 'wss://foo.tld' } | |
> url.format(u); | |
'https://foo.tld/' | |
> url.format(v); | |
'wss://foo.tld' | |
> url.resolve(url.format(u), 'bar'); | |
'https://foo.tld/bar' | |
> url.resolve(url.format(v), 'bar'); | |
'wss://bar' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment