Commit 7ba92885 authored by jan.koester's avatar jan.koester
Browse files

test

parent fccffb4e
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -85,6 +85,19 @@ void webedit::Server::RequestEvent(libhttppp::HttpRequest &curreq,
        std::string url = curreq.getRequestURL();
        std::string prefix = _config.getPrefix();

        // When mounted behind a proxy prefix (e.g. /editor) the browser must
        // see a trailing slash, otherwise relative asset URLs (css/editor.css,
        // js/i18n.js) resolve against the parent path and bypass the prefix.
        // Redirect "/editor" -> "/editor/" once so relative resolution works.
        if (!prefix.empty() && url == prefix) {
            libhttppp::HttpResponse resp;
            resp.setState(HTTP301);
            resp.setHeaderData("Location")->push_back(prefix + "/");
            resp.setContentLength(0);
            resp.send(curreq, "", 0);
            return;
        }

        // Strip prefix
        if (!prefix.empty() && url.find(prefix) == 0)
            url = url.substr(prefix.size());