aboutsummaryrefslogtreecommitdiffstats
path: root/src/uri_utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/uri_utils.h')
-rw-r--r--src/uri_utils.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/uri_utils.h b/src/uri_utils.h
index a22bc7bf..bf5ec3d9 100644
--- a/src/uri_utils.h
+++ b/src/uri_utils.h
@@ -44,11 +44,11 @@ uri_path_at(const SerdURI* uri, size_t i)
}
}
-/** Return true iff `uri` is within the base of `root` */
+/** Return true iff `uri` shares path components with `root` */
static inline bool
-uri_is_under(const SerdURI* uri, const SerdURI* root)
+uri_is_related(const SerdURI* uri, const SerdURI* root)
{
- if (!root || !root->scheme.len ||
+ if (!root || !root->scheme.len || uri->path.len == 1 ||
!slice_equals(&root->scheme, &uri->scheme) ||
!slice_equals(&root->authority, &uri->authority)) {
return false;
@@ -69,6 +69,13 @@ uri_is_under(const SerdURI* uri, const SerdURI* root)
return true;
}
+/** Return true iff `uri` is within the base of `root` */
+static inline bool
+uri_is_under(const SerdURI* uri, const SerdURI* root)
+{
+ return uri->path.len >= root->path.len && uri_is_related(uri, root);
+}
+
static inline bool
is_uri_scheme_char(const uint8_t c)
{