diff options
-rw-r--r-- | src/serdi.c | 18 | ||||
-rw-r--r-- | src/uri.c | 7 | ||||
-rw-r--r-- | tests/test-uri.out | 2 | ||||
-rw-r--r-- | tests/test-uri.ttl | 8 |
4 files changed, 17 insertions, 18 deletions
diff --git a/src/serdi.c b/src/serdi.c index 451905b8..467c3275 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -107,19 +107,13 @@ event_base(void* handle, return false; } - if (!base_uri.scheme.len) { // URI has no scheme, resolve relative URI - SerdURI abs_base_uri; - if (!serd_uri_resolve(&base_uri, &state->base_uri, &abs_base_uri)) { - fprintf(stderr, "error: failed to resolve new base URI\n"); - return false; - } - base_uri_node = serd_node_new_uri(&abs_base_uri, &base_uri); - } else { - SerdURI new_base_uri; - base_uri_node = serd_node_new_uri(&base_uri, &new_base_uri); - base_uri = new_base_uri; + SerdURI abs_base_uri; + if (!serd_uri_resolve(&base_uri, &state->base_uri, &abs_base_uri)) { + fprintf(stderr, "error: failed to resolve new base URI\n"); + return false; } - + base_uri_node = serd_node_new_uri(&abs_base_uri, &base_uri); + state->base_uri_node = base_uri_node; state->base_uri = base_uri; serd_writer_set_base_uri(state->writer, &base_uri); @@ -187,17 +187,12 @@ SERD_API bool serd_uri_resolve(const SerdURI* r, const SerdURI* base, SerdURI* t) { - assert(!r->scheme.len); // r is relative - // See http://tools.ietf.org/html/rfc3986#section-5.2.2 t->path_base.buf = NULL; t->path_base.len = 0; if (r->scheme.len) { - t->scheme = r->scheme; - t->authority = r->authority; - t->path = r->path; - t->query = r->query; + *t = *r; } else { if (r->authority.len) { t->authority = r->authority; diff --git a/tests/test-uri.out b/tests/test-uri.out index 6d717fdd..1517d2e4 100644 --- a/tests/test-uri.out +++ b/tests/test-uri.out @@ -25,3 +25,5 @@ <http://A#afragment> <http://www.w3.org/2002/07/owl#sameAs> <http://A#afragment> . <http://a/b/c/d;p?aquery> <http://www.w3.org/2002/07/owl#sameAs> <http://a/b/c/d;p?aquery> . <http://a/b/c/d;p?q#afragment> <http://www.w3.org/2002/07/owl#sameAs> <http://a/b/c/d;p?q#afragment> . +<http://B/foo> <http://www.w3.org/2002/07/owl#sameAs> <http://B/foo> . +<http://C/bar> <http://www.w3.org/2002/07/owl#sameAs> <http://C/bar> . diff --git a/tests/test-uri.ttl b/tests/test-uri.ttl index 4cae4157..22799360 100644 --- a/tests/test-uri.ttl +++ b/tests/test-uri.ttl @@ -34,3 +34,11 @@ <http://A#afragment> owl:sameAs <http://A#afragment> . <?aquery> owl:sameAs <http://a/b/c/d;p?aquery> . <#afragment> owl:sameAs <http://a/b/c/d;p?q#afragment> . + +@base <http://B?bquery> . + +</foo> owl:sameAs <http://B/foo> . + +@base <http://C#cfragment> . + +</bar> owl:sameAs <http://C/bar> . |