aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri_utils.h
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-03-29 07:28:19 -0400
committerDavid Robillard <d@drobilla.net>2023-12-02 16:27:02 -0500
commitfff826f406e0b9975fd8672041e50dd1a342339f (patch)
tree03a22b89b83a8b26fdf18dd8700e51833b488d81 /src/uri_utils.h
parent94d3433dcf0e77d2c867c9a2dd6928acfea4184c (diff)
downloadserd-fff826f406e0b9975fd8672041e50dd1a342339f.tar.gz
serd-fff826f406e0b9975fd8672041e50dd1a342339f.tar.bz2
serd-fff826f406e0b9975fd8672041e50dd1a342339f.zip
Simplify URI API and implementation
Diffstat (limited to 'src/uri_utils.h')
-rw-r--r--src/uri_utils.h12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/uri_utils.h b/src/uri_utils.h
index ebc32b78..36db5fb5 100644
--- a/src/uri_utils.h
+++ b/src/uri_utils.h
@@ -25,17 +25,17 @@ slice_equals(const SerdStringView* a, const SerdStringView* b)
static inline size_t
uri_path_len(const SerdURIView* uri)
{
- return uri->path_base.length + uri->path.length;
+ return uri->path_prefix.length + uri->path.length;
}
static inline char
uri_path_at(const SerdURIView* uri, size_t i)
{
- if (i < uri->path_base.length) {
- return uri->path_base.data[i];
+ if (i < uri->path_prefix.length) {
+ return uri->path_prefix.data[i];
}
- return uri->path.data[i - uri->path_base.length];
+ return uri->path.data[i - uri->path_prefix.length];
}
/**
@@ -87,7 +87,9 @@ uri_rooted_index(const SerdURIView* uri, const SerdURIView* root)
static inline SERD_PURE_FUNC bool
uri_is_related(const SerdURIView* uri, const SerdURIView* root)
{
- return uri_rooted_index(uri, root).shared != SIZE_MAX;
+ return root && root->scheme.length &&
+ slice_equals(&root->scheme, &uri->scheme) &&
+ slice_equals(&root->authority, &uri->authority);
}
/** Return true iff `uri` is within the base of `root` */