diff options
author | David Robillard <d@drobilla.net> | 2023-05-04 15:14:20 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2023-12-02 18:49:08 -0500 |
commit | e8f392d57bf6eba9b62509a32e4073e8b34b18e2 (patch) | |
tree | c94212eeb8bd015d194f4f6ae4b2bd2327641f94 /src/env.c | |
parent | 3a4bd5f1b31cb5c1522d9e6c7222414342682467 (diff) | |
download | serd-e8f392d57bf6eba9b62509a32e4073e8b34b18e2.tar.gz serd-e8f392d57bf6eba9b62509a32e4073e8b34b18e2.tar.bz2 serd-e8f392d57bf6eba9b62509a32e4073e8b34b18e2.zip |
[WIP] Remove serd_new_resolved_uri()
Diffstat (limited to 'src/env.c')
-rw-r--r-- | src/env.c | 33 |
1 files changed, 12 insertions, 21 deletions
@@ -209,8 +209,14 @@ serd_env_set_prefix(SerdEnv* const env, return SERD_BAD_ARG; } - // Resolve relative URI and create a new node and URI for it - SerdNode* const abs_uri = serd_new_resolved_uri(uri, env->base_uri); + // Resolve potentially relative URI reference to an absolute URI + const SerdURIView uri_view = serd_parse_uri(uri.data); + const SerdURIView abs_uri_view = serd_resolve_uri(uri_view, env->base_uri); + assert(abs_uri_view.scheme.length); + + // Create a new node for the absolute URI + SerdNode* const abs_uri = serd_new_parsed_uri(abs_uri_view); + assert(serd_uri_string_has_scheme(serd_node_string(abs_uri))); // Set prefix to resolved (absolute) URI serd_env_add(env, name, serd_node_string_view(abs_uri)); @@ -269,14 +275,6 @@ serd_env_expand_in_place(const SerdEnv* const env, return SERD_SUCCESS; } -static SerdNode* -expand_uri(const SerdEnv* env, const SerdNode* node) -{ - assert(serd_node_type(node) == SERD_URI); - - return serd_new_resolved_uri(serd_node_string_view(node), env->base_uri); -} - SerdNode* serd_env_expand_curie(const SerdEnv* const env, const SerdStringView curie) { @@ -305,21 +303,14 @@ serd_env_expand_curie(const SerdEnv* const env, const SerdStringView curie) SerdNode* serd_env_expand_node(const SerdEnv* const env, const SerdNode* const node) { - if (!env || !node) { + if (!env || !node || node->type != SERD_URI) { return NULL; } - switch (node->type) { - case SERD_LITERAL: - break; - case SERD_URI: - return expand_uri(env, node); - case SERD_BLANK: - case SERD_VARIABLE: - break; - } + const SerdURIView uri = serd_node_uri_view(node); + const SerdURIView abs_uri = serd_resolve_uri(uri, env->base_uri); - return NULL; + return abs_uri.scheme.length ? serd_new_parsed_uri(abs_uri) : NULL; } SerdStatus |