Skip to content
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

Odd corner case of InvalidURIError #39

Closed
egonSchiele opened this issue Jun 27, 2011 · 2 comments
Closed

Odd corner case of InvalidURIError #39

egonSchiele opened this issue Jun 27, 2011 · 2 comments
Labels

Comments

@egonSchiele
Copy link

The following code:
Addressable::URI.join "http://www.good.is/post/sponsored-post-how-corporations-are-harnessing-the-power-of-renewable-energy/", "//"

Gives:
Absolute URI missing hierarchical segment: 'http://' (Addressable::URI::InvalidURIError)

This doesn't happen with any of the following:
Addressable::URI.join "http://www.good.is/post/sponsored-post-how-corporations-are-harnessing-the-power-of-renewable-energy/", "/"
Addressable::URI.join "http://www.good.is/post/sponsored-post-how-corporations-are-harnessing-the-power-of-renewable-energy/", "/?a"
Addressable::URI.join "http://www.good.is/post/sponsored-post-how-corporations-are-harnessing-the-power-of-renewable-energy/", "///"

@sporkmonger
Copy link
Owner

Yeah, this definitely looks like a problem. Could you try to produce a more condensed test-case that duplicates the issue? Basically, I need the simplest URI that fails in this manner.

@sporkmonger
Copy link
Owner

Wait, no... actually I didn't look at this closely enough. This is working very much as intended. You've probably just misunderstood what's actually happening here.

That function is equivalent to this:

Addressable::URI.parse("http://example.com/") + Addressable::URI.parse("//")

That second URI resolves to a network-path reference with a host and path of "". This essentially means that the joined URI resolves to "http://", which is not a valid URI. However, the other examples you gave resolve to valid URIs: "http://example.com/", "http://example.com/?a", and "http:///" respectively.

Closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants