From 0509472636b243775502d801f15746c5d9076dab Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 7 Sep 2019 23:57:33 +0200 Subject: [PATCH] util/UriExtract: add uri_is_relative_path() --- src/util/UriExtract.cxx | 6 ++++++ src/util/UriExtract.hxx | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/util/UriExtract.cxx b/src/util/UriExtract.cxx index c71019bcb..3a0e356ce 100644 --- a/src/util/UriExtract.cxx +++ b/src/util/UriExtract.cxx @@ -95,6 +95,12 @@ uri_get_scheme(const char *uri) noexcept return {uri, end}; } +bool +uri_is_relative_path(const char *uri) noexcept +{ + return !uri_has_scheme(uri) && *uri != '/'; +} + const char * uri_get_path(const char *uri) noexcept { diff --git a/src/util/UriExtract.hxx b/src/util/UriExtract.hxx index 628fe6f90..1d96e6fc8 100644 --- a/src/util/UriExtract.hxx +++ b/src/util/UriExtract.hxx @@ -49,6 +49,10 @@ gcc_pure StringView uri_get_scheme(const char *uri) noexcept; +gcc_pure +bool +uri_is_relative_path(const char *uri) noexcept; + /** * Returns the URI path (including the query string) or nullptr if the * given URI has no path.