-
Notifications
You must be signed in to change notification settings - Fork 266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
URI Parse Error #376
Comments
I understand where you are coming from. A
Feel free to check out https://github.com/twingly/twingly-url, I think it can handle your cases: irb(main):004:0> Twingly::URL.parse("https://")
=> #<Twingly::URL::NullURL:0x00007fe6dc981258>
irb(main):005:0> Twingly::URL.parse("http://")
=> #<Twingly::URL::NullURL:0x00007fe6dca1b9c0>
irb(main):006:0> Twingly::URL.parse("!")
=> #<Twingly::URL::NullURL:0x00007fe6dca134a0>
irb(main):007:0> Twingly::URL.parse("!").valid?
=> false (Note that some things (like the normalization) in twingly-url is purposefully built according to specific needs from Twingly (I work there)) |
I will close this as a duplicate of #257 |
Hi @dentarg, Thanks for your comments. With respect, this issue isn't a duplicate of #257. I don't want an The |
Okay, I see. This issue will stay closed because the behaviour you are seeing is intentional, see #216 (comment) for an explanation.
$ irb -r addressable/uri
irb(main):001:0> Addressable::URI.parse("!")
=> #<Addressable::URI:0x3fd5d486a774 URI:!>
irb(main):002:0> Addressable::URI.parse("!").relative?
=> true |
Are there any other Strings (besides |
I don't know, but feel free to read the source code. :-) |
@michaeltelford Also, feel free to take a look here: https://github.com/twingly/twingly-url/blob/bf5fa7ba54fa212a04f7aa8fdc77c92927c4c361/spec/lib/twingly/url_spec.rb#L7-L52 |
I'm running
ruby 2.5.3
andaddressable 2.7.0
.Consider the following:
Some might argue that it's OK to fail here because
http://
is indeed an invalid URL. However, so is the following, which parses successfully:In the interest of making the code as robust as possible, is it not best to support the parsing of
http://
(andhttps://
)? My program extracts links from webpages before parsing them withAddressable::URI.parse
. Since you get all sorts of crap on the web, it would be good to be able to support this scenario in Addressable rather than me having to implement a work-a-round.The text was updated successfully, but these errors were encountered: