Improve URI matching algorithm

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2021-01-25 20:10:43 +01:00
parent e8e4c5f180
commit fa4c194045
4 changed files with 54 additions and 53 deletions
+6 -2
View File
@@ -146,9 +146,13 @@ const char* __attribute__((pure)) startsWith(const char *path, const struct ftl_
if(api->request->local_uri[strlen(path)] == '/')
// Path match with argument after ".../"
return api->request->local_uri + strlen(path) + 1u;
else
// Path match without argument
else if(strlen(path) == strlen(api->request->local_uri))
// Path match directly, no argument
return "";
else
// Further components in URL, assume this did't match, e.g.
// /api/domains/regex[123].com
return NULL;
else
// Path does not match
return NULL;