diff --git a/src/uri/uri.cc b/src/uri/uri.cc index e069cd461..c34cdcb46 100644 --- a/src/uri/uri.cc +++ b/src/uri/uri.cc @@ -514,6 +514,12 @@ auto URI::relative_to(const URI &base) -> URI & { } uriFreeUriMembersMmA(&result, nullptr); + + // TODO: Why do we even need to do this? + if (copy.data.starts_with('/')) { + copy.data.erase(0, 1); + } + copy.parse(); // `uriparser` has this weird thing where it will only look at scheme and diff --git a/test/uri/uri_relative_to_test.cc b/test/uri/uri_relative_to_test.cc index 7e0770b4b..54db19b74 100644 --- a/test/uri/uri_relative_to_test.cc +++ b/test/uri/uri_relative_to_test.cc @@ -77,3 +77,10 @@ TEST(URI_relative_to, relative_relative_1) { uri.relative_to(base); EXPECT_EQ(uri.recompose(), "foo/bar/baz"); } + +TEST(URI_relative_to, urn_1) { + const sourcemeta::jsontoolkit::URI base{"schema:"}; + sourcemeta::jsontoolkit::URI uri{"schema:myschema"}; + uri.relative_to(base); + EXPECT_EQ(uri.recompose(), "myschema"); +}