fix: use correct location match segment
This commit is contained in:
parent
5076ab0630
commit
5a1d8a1dcf
@ -36,16 +36,21 @@ const AConfig *URI::matchConfig(const std::string &uri, const ServerConfig &serv
|
|||||||
{
|
{
|
||||||
return serverConfig.getLocation(locationPath);
|
return serverConfig.getLocation(locationPath);
|
||||||
}
|
}
|
||||||
// TODO this matches only prefix, need to handle exact match
|
if (!uri.starts_with(utils::trim(locationPath, "/")))
|
||||||
if (uri.starts_with(utils::trim(locationPath, "/")))
|
|
||||||
{
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (uri.substr(utils::trim(locationPath, "/").length())[0] != '/'
|
||||||
|
|| !uri.substr(utils::trim(locationPath, "/").length()).empty())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (locationPath.length() > maxMatchLength)
|
if (locationPath.length() > maxMatchLength)
|
||||||
{
|
{
|
||||||
maxMatchLength = locationPath.length();
|
maxMatchLength = locationPath.length();
|
||||||
bestMatch = serverConfig.getLocation(locationPath);
|
bestMatch = serverConfig.getLocation(locationPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return bestMatch;
|
return bestMatch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user