Skip to content

Instantly share code, notes, and snippets.

@Rolinh Rolinh/url.js
Last active Oct 4, 2016

Embed
What would you like to do?
nodejs url.resolve() bug
> 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
You can’t perform that action at this time.