Closed kernelmethod closed 3 years ago
I believe that this is what URIs.absuri
tries to do, but this seems more general. I propose to deprecated URIs.absuri
in favor of this function.
This will also close https://github.com/JuliaWeb/HTTP.jl/issues/435 and https://github.com/JuliaWeb/HTTP.jl/issues/626 and maybe https://github.com/JuliaWeb/URIs.jl/issues/21 ?
Thanks for the review @fredrikekre, I've applied the changes you've suggested
Edit: also, I've tried the example from #21 and I've confirmed that using resolvereference
will get the expected result, so this should close that issue too.
I've tried the example from #21 and I've confirmed that using resolvereference will get the expected result, so this should close that issue too.
But only if you used resolvereference
instead of joinpath
, right? Perhaps joinpath
should be updated to call resolvereference
?
But only if you used
resolvereference
instead ofjoinpath
, right?
Yes, correct.
Perhaps
joinpath
should be updated to callresolvereference
?
Possibly? resolvereference
and joinpath
are quite similar in their purpose (as I noted in #18), but resolvereference
explicitly complies with RFC 3986 Sec. 5.2 (and hence with URI resolution methods in other languages, including the JavaScript example from #21). It'd probably be nice if joinpath
called resolvereference
under the hood, but I'm not sure if there's a way to do so that doesn't break the current behavior of joinpath
.
If we aren't worried about breaking joinpath
's behavior, though, we could probably very easily redefine it as
Base.joinpath(base::URI, parts...) = reduce(resolvereference, [base, parts...])
(or something similar).
RFC 3986 Section 5.2 (https://tools.ietf.org/html/rfc3986#section-5.2) defines an method for resolving references relative to a base URI. This pull request adds the
resolvereference
function in order to achieve this functionality, which attempts to comply with the algorithm defined in Section 5.2.2.Closes #18.