From d6d1deccc64f587450e7f5f58b7322c51f32ae89 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Thu, 13 Sep 2018 23:34:40 -0700 Subject: [PATCH] ircd::resource: Tweak resource path search and fallback to webroot. --- ircd/resource.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ircd/resource.cc b/ircd/resource.cc index b74b4d5fe..301a7b416 100644 --- a/ircd/resource.cc +++ b/ircd/resource.cc @@ -47,7 +47,7 @@ ircd::resource::find(const string_view &path_) return *it->second; // Directories handle all paths under them. - if(!startswith(path, rpath)) + while(!startswith(path, rpath)) { // Walk the iterator back to find if there is a directory prefixing this path. if(it == begin(resources)) @@ -58,11 +58,13 @@ ircd::resource::find(const string_view &path_) --it; rpath = it->first; + if(~it->second->flags & it->second->DIRECTORY) + continue; + + // If the closest directory still doesn't match hand this off to the + // webroot which can then service or 404 this itself. if(!startswith(path, rpath)) - throw http::error - { - http::code::NOT_FOUND - }; + return *resources.at("/"); } // Check if the resource is a directory; if not, it can only