aboutsummaryrefslogtreecommitdiff
path: root/src/content/static/Static.cpp
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2021-10-14 18:41:55 +0200
committerToni Uhlig <matzeton@googlemail.com>2021-10-14 18:41:55 +0200
commit51d9d23c99d77edad03e6425f3ab35a390156117 (patch)
tree82b632c2aac22c3d79f43e427f311a46591f30ca /src/content/static/Static.cpp
parentf0f4b8a4d139a855ad15f9d79190edf6320eba51 (diff)
Blog Metadata parsing, validationa and templating.
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
Diffstat (limited to 'src/content/static/Static.cpp')
-rw-r--r--src/content/static/Static.cpp12
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;
}