Open ccorcos opened 6 years ago
I met this too.
i judge protocol exists before parse:
if (/http/gi.test(url)) {
url.parse(url)
}
hope it can help you .
What does node's core url
module do here?
(specifically, without a protocol, it's not actually a URL, so this might simply be user error)
I have seen many cases of protocol less links such as //google.com which are annoying. Everyone should always just use SSL and https.
This library does not correctly handle these links well but you can use regex to look for //. I may fork and update this package.
This library doesnt seem to parse the host properly when there isnt a protocol.
> u.parse("www.google.com/yay?q=10&q=12") Url { protocol: null, slashes: null, auth: null, host: null, port: null, hostname: null, hash: null, search: '?q=10&q=12', query: 'q=10&q=12', pathname: 'www.google.com/yay', path: 'www.google.com/yay?q=10&q=12', href: 'www.google.com/yay?q=10&q=12' }
Without // , http or https, it's not a domain.
www.google.com/yay?q=10&q=12
needs to have // instead of www.
@ameshkin this library matches what node’s core url module does, so if that one doesn’t do it, this one shouldn’t either.
This library doesnt seem to parse the host properly when there isnt a protocol.