You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
url.format does not postfix :// when parsed url is not fully qualified but a protocol is specified #4101
Seeing as how modifying the url module would be more drastic and could have unintended effects in userland, I'd say going with the doc fix is the safer approach, sent a PR.
Altering the url module would definitely effect many users, but the current behavior isn't very useful. I was hoping to use the url module to convert any partial/full url to a full url, eg:
I didn't try with slashes, thanks for pointing it out.
Unfortunately, when I set slashes to true, the formatted url came out with three slashes because when the simple "www.google.com" url is parsed, there is no hostname. (instead it's put into pathname/path).
Yeah, the url module needs a breaking change to fix that stuff. After my PR for doc change lands, I'll get around submitting another one for this kind of stuff.
Activity
claudiorodriguez commentedon Dec 2, 2015
See #3361 and #4097
claudiorodriguez commentedon Dec 2, 2015
Seeing as how modifying the url module would be more drastic and could have unintended effects in userland, I'd say going with the doc fix is the safer approach, sent a PR.
Jonahss commentedon Dec 2, 2015
Fixing the docs def fixes confusion.
Altering the url module would definitely effect many users, but the current behavior isn't very useful. I was hoping to use the url module to convert any partial/full url to a full url, eg:
Should I publish a module to perform this common operation?
claudiorodriguez commentedon Dec 3, 2015
For your particular use case, isn't it sufficient to set "slashes" to true on the url object, then format?
Jonahss commentedon Dec 4, 2015
I didn't try with
slashes, thanks for pointing it out.Unfortunately, when I set
slashestotrue, the formatted url came out with three slashes because when the simple "www.google.com" url is parsed, there is no hostname. (instead it's put into pathname/path).So I guess my function will need to do this:
Of course, now if my original text had a path, it would never be parsed out.
I guess moral of the story is prepend "http://" to any input url that doesn't have a protocol and parse from there.
claudiorodriguez commentedon Dec 4, 2015
Yeah, the url module needs a breaking change to fix that stuff. After my PR for doc change lands, I'll get around submitting another one for this kind of stuff.
Jonahss commentedon Dec 7, 2015
👍
NamespaceValentine commentedon Mar 22, 2016
+1 is there a current workaround for this or an eta on completion?
bnoordhuis commentedon Feb 7, 2017
I'll close this out. url.format() is frozen for practical purposes, bugs and all, and superseded by the WHATWG URL implementation.