diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/env.c | 31 | ||||
-rw-r--r-- | src/uri.c | 3 |
2 files changed, 25 insertions, 9 deletions
@@ -278,15 +278,34 @@ expand_literal(const SerdEnv* env, const SerdNode* node) assert(serd_node_type(node) == SERD_LITERAL); const SerdNode* const datatype = serd_node_datatype(node); - if (datatype && serd_node_type(datatype) == SERD_CURIE) { + if (!datatype) { + return serd_node_copy(node); + } + + if (serd_node_type(datatype) == SERD_CURIE) { SerdStringView prefix; SerdStringView suffix; - if (!serd_env_expand_in_place(env, datatype, &prefix, &suffix)) { - return serd_new_typed_literal_expanded( - serd_node_string_view(node), serd_node_flags(node), SERD_URI, prefix, suffix); + if (serd_env_expand_in_place(env, datatype, &prefix, &suffix)) { + return NULL; + } + + return serd_new_typed_literal_expanded(serd_node_string_view(node), + serd_node_flags(node), + SERD_URI, + prefix, + suffix); + } + + if (serd_node_type(datatype) == SERD_URI) { + const SerdURIView datatype_uri = serd_parse_uri(serd_node_string(datatype)); + + const SerdURIView abs_datatype_uri = + serd_resolve_uri(datatype_uri, env->base_uri); + + if (!abs_datatype_uri.scheme.len) { + return NULL; } - } else if (datatype && serd_node_type(datatype) == SERD_URI) { return serd_new_typed_literal_uri( serd_node_string_view(node), serd_node_flags(node), @@ -336,7 +355,7 @@ serd_env_expand(const SerdEnv* env, const SerdNode* node) case SERD_CURIE: return expand_curie(env, node); case SERD_BLANK: - return NULL; + return serd_node_copy(node); } } @@ -283,9 +283,6 @@ serd_resolve_uri(const SerdURIView r, const SerdURIView base) SerdURIView t = SERD_URI_NULL; - t.path_prefix.buf = NULL; - t.path_prefix.len = 0; - if (r.authority.len) { t.authority = r.authority; t.path = r.path; |