diff options
-rw-r--r-- | serd/serd.h | 4 | ||||
-rw-r--r-- | src/serdi.c | 9 | ||||
-rw-r--r-- | src/uri.c | 7 | ||||
-rw-r--r-- | src/writer.c | 11 |
4 files changed, 12 insertions, 19 deletions
diff --git a/serd/serd.h b/serd/serd.h index d7115054..25237371 100644 --- a/serd/serd.h +++ b/serd/serd.h @@ -147,9 +147,9 @@ SERD_API bool serd_uri_parse(const uint8_t* utf8, SerdURI* out); -/** Resolve @a uri relative to @a base, writing result to @a out. */ +/** Set @a out to @a uri resolved against @a base. */ SERD_API -bool +void serd_uri_resolve(const SerdURI* uri, const SerdURI* base, SerdURI* out); /** Sink function for raw string output. */ diff --git a/src/serdi.c b/src/serdi.c index e85c9f70..ed64dfb8 100644 --- a/src/serdi.c +++ b/src/serdi.c @@ -51,10 +51,7 @@ event_base(void* handle, } 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; - } + serd_uri_resolve(&base_uri, &state->base_uri, &abs_base_uri); base_uri_node = serd_node_new_uri(&abs_base_uri, &base_uri); serd_node_free(&state->base_uri_node); @@ -76,9 +73,7 @@ event_prefix(void* handle, return false; } SerdURI abs_uri; - if (!serd_uri_resolve(&uri, &state->base_uri, &abs_uri)) { - return false; - } + serd_uri_resolve(&uri, &state->base_uri, &abs_uri); SerdURI base_uri; SerdNode base_uri_node = serd_node_new_uri(&abs_uri, &base_uri); serd_env_add(state->env, name, &base_uri_node); @@ -186,7 +186,7 @@ end: } SERD_API -bool +void serd_uri_resolve(const SerdURI* r, const SerdURI* base, SerdURI* t) { // See http://tools.ietf.org/html/rfc3986#section-5.2.2 @@ -217,9 +217,9 @@ serd_uri_resolve(const SerdURI* r, const SerdURI* base, SerdURI* t) } t->authority = base->authority; } - t->scheme = base->scheme; + t->scheme = base->scheme; + t->fragment = r->fragment; } - t->fragment = r->fragment; #ifdef URI_DEBUG fprintf(stderr, "RESOLVE URI\nBASE:\n"); @@ -230,7 +230,6 @@ serd_uri_resolve(const SerdURI* r, const SerdURI* base, SerdURI* t) serd_uri_dump(t, stderr); fprintf(stderr, "\n"); #endif - return true; } SERD_API diff --git a/src/writer.c b/src/writer.c index dd1d3f7a..44d88b99 100644 --- a/src/writer.c +++ b/src/writer.c @@ -220,12 +220,11 @@ write_node(SerdWriter writer, SerdURI uri; if (serd_uri_parse(node->buf, &uri)) { SerdURI abs_uri; - if (serd_uri_resolve(&uri, &writer->base_uri, &abs_uri)) { - writer->sink("<", 1, writer->stream); - serd_uri_serialise(&abs_uri, writer->sink, writer->stream); - writer->sink(">", 1, writer->stream); - return true; - } + serd_uri_resolve(&uri, &writer->base_uri, &abs_uri); + writer->sink("<", 1, writer->stream); + serd_uri_serialise(&abs_uri, writer->sink, writer->stream); + writer->sink(">", 1, writer->stream); + return true; } } else { writer->sink("<", 1, writer->stream); |