diff options
author | Jo-Philipp Wich <jo@mein.io> | 2016-10-25 16:23:05 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2016-10-25 16:32:50 +0200 |
commit | 1628fa4b34aa143187353f81e8001b9a15286bda (patch) | |
tree | 0f4cc4bab29f706d0f46e3cec46fc4d9429979f8 /utils.c | |
parent | 577c20c5f780a241d526b16345cf42ea81b675ab (diff) |
utils: add proper handling of "/" special case in uh_path_match()
The special prefix of "/" should match any url by definition but the final
assertion which ensures that the matched prefix ends in '\0' or '/' is causing
matches against the "/" prefix to fail.
Add some extra code to handle this special case to implemented the expected
behaviour.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -208,6 +208,10 @@ bool uh_path_match(const char *prefix, const char *url) { int len = strlen(prefix); + /* A prefix of "/" will - by definition - match any url */ + if (prefix[0] == '/' && len == 1) + return true; + if (strncmp(url, prefix, len) != 0) return false; |