summaryrefslogtreecommitdiffhomepage
path: root/config.cpp
diff options
context:
space:
mode:
authorRoland Reichwein <mail@reichwein.it>2020-04-06 21:54:33 +0200
committerRoland Reichwein <mail@reichwein.it>2020-04-06 21:54:33 +0200
commitf5e2c43abe9477fba6255c734faf2822e7f2f9c5 (patch)
tree7c112598eb732f14a44299b12bbc48ee07521a60 /config.cpp
parent0ff6671cec0bc8db106f094400425ada5d4faf7a (diff)
Fix DocRoot to match longest prefix
Diffstat (limited to 'config.cpp')
-rw-r--r--config.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/config.cpp b/config.cpp
index 6dbd8ee..baf611b 100644
--- a/config.cpp
+++ b/config.cpp
@@ -189,6 +189,7 @@ std::string Config::DocRoot(const Socket& socket, const std::string& requested_h
{
// TODO: speed this up
std::string host{requested_host};
+ std::string result;
auto pos {host.find(':')};
if (pos != host.npos) {
@@ -201,7 +202,9 @@ std::string Config::DocRoot(const Socket& socket, const std::string& requested_h
if (m_host == host) {
for (const auto& path: site.paths) {
if (boost::starts_with(requested_path, path.requested)) {
- return path.params.at("target");
+ const auto& root { path.params.at("target")};
+ if (root.size() > result.size())
+ result = root;
}
}
}
@@ -209,6 +212,6 @@ std::string Config::DocRoot(const Socket& socket, const std::string& requested_h
}
}
- return "";
+ return result;
}