kasei / perl-iri

Perl implementation of Internationalized Resource Identifiers (IRIs)
0 stars 6 forks source link

From absolute to relative IRI? #15

Open kjetilk opened 5 years ago

kjetilk commented 5 years ago

There is code to go from a relative IRI to an absolute IRI, but can we go the other way?

Say that we have e.g.

my $iri = IRI->new(value => "http://www.hestebedg\x{e5}rd.dk/hest/ku");

and then, from some other place, I get the base

my $base = IRI->new(value => "http://www.hestebedg\x{e5}rd.dk/hest");

Can I somehow get the relative URI (or just the string) /ku?

If not, then, that's on my wishlist :-)

kasei commented 5 years ago

That's on my wishlist, too. I started work on this in the rel branch, but I recall it having some complicated corner-cases that I wasn't able to address in the time I spent on it.

kjetilk commented 5 years ago

Oh, OK, I wasn't aware. I can't see any branches though, could you please push it here?

kasei commented 5 years ago

Oops!

kasei commented 5 years ago

Just a warning, I'm not sure where I left the code in the rel branch. There's some code, and tests, but no guarantees that the tests cover all cases, or that the code is the right approach! :)

kjetilk commented 5 years ago

OK, interesting!

So, was the corner case of such a nature that it could break things, or just a suboptimal case?

kasei commented 5 years ago

I don't remember. I can look into the code tomorrow and try to figure out where I left things, but I can't do it tonight.

kasei commented 5 years ago

My main concern was avoiding a situation where I released code that did the wrong thing for the corner cases, without being able to identify them and at least fall back on bailing out and just using absolute IRIs.

kjetilk commented 5 years ago

Oh, great! Don't worry, it wasn't an immediate need, it just struck me as something that would have been a great enabler in many designs.

kasei commented 5 years ago

Agreed. I'd love to get this sorted out. I just have so many things fighting for my time at the moment!