When calculating the matching prefix length, make sure to not take the trailing
slash into account in order to ensure that the resulting PATH_INFO string
always starts with a slash.
This ensures that an url like "/foo" against the matching prefix "/" or
"/foo/bar" against "/foo/" result in "/foo" and "/bar" respectively.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
pi->query = str + 1;
path_len = str - url;
}
+
+ if (prefix_len > 0 && conf.lua_prefix[prefix_len - 1] == '/')
+ prefix_len--;
+
if (path_len > prefix_len) {
lua_pushlstring(L, url + prefix_len,
path_len - prefix_len);