Hi..
I feel like this should work.
$ URI.parse("/base/uri") + URI.parse("relative")
URI::BadURIError: both URI are relative
The result should be URI with path = "/base/relative".
What do you think? Is this a bug? Or is it designed like this on purpose?
Kind regards,
Samuel
This gets into the hazy zone where you have to work out whether a
"relative reference" is a "URI." RFC 3986, Section 4.1
<https://tools.ietf.org/html/rfc3986#section-4.1>, says that an absolute
URI and a relative reference are different, but are both types of "URI
reference".
So it's correct according to spec that you can't parse a relative reference
using the URI module. However it's also true that it could be quite useful
to have a library that unifies "URI references," like you're trying to do.
Cheers
···
On 31 October 2016 at 08:44, Samuel Williams <space.ship.traveller@gmail.com > wrote:
Hi..
I feel like this should work.
$ URI.parse("/base/uri") + URI.parse("relative")
URI::BadURIError: both URI are relative
The result should be URI with path = "/base/relative".
What do you think? Is this a bug? Or is it designed like this on purpose?
Kind regards,
Samuel
--
Matthew Kerwin
http://matthew.kerwin.net.au/
I decided to file a bug report for the discussion
https://bugs.ruby-lang.org/issues/12886
Matthew, your feedback is informative and thanks for pulling details
from an RFC.
you can't parse a relative reference using the URI module
It is possible to parse relative URIs using the current code. For example:
URI.parse("a/b") + URI.parse("c")
URI::BadURIError: both URI are relative
But it's perfectly fine to write URI.parse("a/c") (i.e. parse a
relative URI reference).
···
On 31 October 2016 at 12:07, Matthew Kerwin <matthew@kerwin.net.au> wrote:
On 31 October 2016 at 08:44, Samuel Williams > <space.ship.traveller@gmail.com> wrote:
Hi..
I feel like this should work.
$ URI.parse("/base/uri") + URI.parse("relative")
URI::BadURIError: both URI are relative
The result should be URI with path = "/base/relative".
What do you think? Is this a bug? Or is it designed like this on purpose?
Kind regards,
Samuel
This gets into the hazy zone where you have to work out whether a "relative
reference" is a "URI." RFC 3986, Section 4.1, says that an absolute URI and
a relative reference are different, but are both types of "URI reference".
So it's correct according to spec that you can't parse a relative reference
using the URI module. However it's also true that it could be quite useful
to have a library that unifies "URI references," like you're trying to do.
Cheers
--
Matthew Kerwin
http://matthew.kerwin.net.au/
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Yeah, sorry, lazy writing on my part. You can't resolve a relative
reference against a relative reference, which is what
URI::Generic
calls `
merge
` or `
···
On 31 October 2016 at 09:12, Samuel Williams <space.ship.traveller@gmail.com > wrote:
I decided to file a bug report for the discussion
https://bugs.ruby-lang.org/issues/12886
Matthew, your feedback is informative and thanks for pulling details
from an RFC.
> you can't parse a relative reference using the URI module
It is possible to parse relative URIs using the current code. For example:
URI.parse("a/b") + URI.parse("c")
URI::BadURIError: both URI are relative
But it's perfectly fine to write URI.parse("a/c") (i.e. parse a
relative URI reference).
+
`
--
Matthew Kerwin
http://matthew.kerwin.net.au/
Just for the hell of it I made a PR, since I had a monkey patch lying
around anyway.
Any and all feedback is welcome
Thanks.
···
On 31 October 2016 at 12:27, Matthew Kerwin <matthew@kerwin.net.au> wrote:
On 31 October 2016 at 09:12, Samuel Williams > <space.ship.traveller@gmail.com> wrote:
I decided to file a bug report for the discussion
https://bugs.ruby-lang.org/issues/12886
Matthew, your feedback is informative and thanks for pulling details
from an RFC.
> you can't parse a relative reference using the URI module
It is possible to parse relative URIs using the current code. For example:
URI.parse("a/b") + URI.parse("c")
URI::BadURIError: both URI are relative
But it's perfectly fine to write URI.parse("a/c") (i.e. parse a
relative URI reference).
Yeah, sorry, lazy writing on my part. You can't resolve a relative reference
against a relative reference, which is what
URI::Generic
calls `
merge
` or `
+
`
--
Matthew Kerwin
http://matthew.kerwin.net.au/
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>
Matthew, I though a bit more about what you said on the bug report. I
tried to reply but bugs.ruby-lang is just saying "Application Error".
Anyway here is my response:
Matthew, thanks for providing some additional details.
I agree with your points, sticking to the definition of the
[RFC](https://tools.ietf.org/html/rfc3986#section-4.2) makes sense.
Then, according to the RFC, this implementation is wrong in many ways.
For example, `URI("a/b")` should not parse and raise an error. Because
it doesn't, it causes confusion.
Either the API should completely support working with both URIs and
relative references, or it shouldn't. Otherwise, it's confusing when
some things work and others don't.
What might make more sense, is to add URI#relative_reference? and have
URI handle this case. I can expand the [PR I made
here](https://github.com/ruby/ruby/pull/1469) to add that.
···
On 31 October 2016 at 12:41, Samuel Williams <space.ship.traveller@gmail.com> wrote:
Just for the hell of it I made a PR, since I had a monkey patch lying
around anyway.
https://github.com/ruby/ruby/pull/1469
Any and all feedback is welcome
Thanks.
On 31 October 2016 at 12:27, Matthew Kerwin <matthew@kerwin.net.au> wrote:
On 31 October 2016 at 09:12, Samuel Williams >> <space.ship.traveller@gmail.com> wrote:
I decided to file a bug report for the discussion
https://bugs.ruby-lang.org/issues/12886
Matthew, your feedback is informative and thanks for pulling details
from an RFC.
> you can't parse a relative reference using the URI module
It is possible to parse relative URIs using the current code. For example:
URI.parse("a/b") + URI.parse("c")
URI::BadURIError: both URI are relative
But it's perfectly fine to write URI.parse("a/c") (i.e. parse a
relative URI reference).
Yeah, sorry, lazy writing on my part. You can't resolve a relative reference
against a relative reference, which is what
URI::Generic
calls `
merge
` or `
+
`
--
Matthew Kerwin
http://matthew.kerwin.net.au/
Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>