0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-01 01:28:54 +02:00

ircd::resource: Tweak resource path search and fallback to webroot.

This commit is contained in:
Jason Volk 2018-09-13 23:34:40 -07:00
parent 84a09918b2
commit d6d1deccc6

View file

@ -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