diff options
Diffstat (limited to 'src/content/static/Static.cpp')
-rw-r--r-- | src/content/static/Static.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/content/static/Static.cpp b/src/content/static/Static.cpp index b9977a9..132f0a0 100644 --- a/src/content/static/Static.cpp +++ b/src/content/static/Static.cpp @@ -6,7 +6,6 @@ Static::Static(std::string uriBasePath, std::shared_ptr<Filesystem> const & fs) for (auto const & file : fs->GetFiles()) { m_Redirections.push_back(uriBasePath + "/" + file.first); - m_UriToFsMapping[uriBasePath + "/" + file.first] = file.first; } } @@ -26,16 +25,21 @@ bool Static::Render(RequestResponse & rr, RenderData & rd, std::string & out) { (void)rd; + if (rr.GetUriPath() == m_UriBasePath) + { + return false; + } + rr.UseOutputHeader(); auto & files = m_StaticFiles->GetFiles(); - auto const & path = std::string(rr.GetUriPath()); + auto const & path = std::string(rr.GetUriPath()).substr(m_UriBasePath.length() + 1, std::string::npos); - if (rr.AddOutputHeader("Content-Type", files[m_UriToFsMapping[path]].mime) == false) + if (rr.AddOutputHeader("Content-Type", files[path].mime) == false) { return false; } - out = std::string(files[m_UriToFsMapping[path]].data.begin(), files[m_UriToFsMapping[path]].data.end()); + out = std::string(files[path].data.begin(), files[path].data.end()); return true; } |