drobilla / serd

A lightweight C library for RDF syntax
https://gitlab.com/drobilla/serd
ISC License
88 stars 16 forks source link

Resolution for base URIs with empty path #21

Closed wouterbeek closed 6 years ago

wouterbeek commented 6 years ago

When the base URI's path is empty (e.g., https://a.org), resolution of URIs gives incorrect results. E.g., relative URI b resolves to absolute URI https://a.orgb, whereas https://a.org/b was expected.

drobilla commented 6 years ago

Hmm... turns out this might not be so trivial. Serd's URI resolution is written to be in-place, so no allocation of new nodes needs to be done when streaming, but this special case messes that up, since a slash needs to come from somewhere that doesn't exist.

Maybe I can instead tinker with the serialisation stuff to detect this case and emit an extra slash. This wouldn't make a slash magically appear for people manually using serd_uri_resolve and friends, but it should be possible to handle it everywhere a resolved URI is actually serialized (either with the writer or to a new node). My only concern is that this could mess up weird URI schemes, but you can't have an authority and a path without a delimiter, so I think this is fine as long as an authority is actually present...

drobilla commented 6 years ago

3267bb312f50746202226d29cc196bb47941e4d5 should do it.