Redirect /https://... to /...

This commit is contained in:
blankie 2023-11-24 10:59:22 +11:00
parent 8b443062eb
commit e31cd4e9be
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 5 additions and 5 deletions

View File

@ -40,16 +40,16 @@ int main(int argc, char** argv) {
server.Get("/style.css", css_route);
server.Get("/(" DOMAIN_RE ")/@(" ACCT_RE ")(|/with_replies|/media)", user_route);
server.Get("/(" DOMAIN_RE ")/users/(" ACCT_RE ")(|/with_replies|/media)", [](const httplib::Request& req, httplib::Response& res) {
using namespace std::string_literals;
serve_redirect(req, res, "/"s + req.matches.str(1) + "/@" + req.matches.str(2) + req.matches.str(3), true);
serve_redirect(req, res, get_origin(req) + '/' + req.matches.str(1) + "/@" + req.matches.str(2) + req.matches.str(3), true);
});
server.Get("/(" DOMAIN_RE ")/@" ACCT_RE "/(\\d+)", status_route);
server.Get("/(" DOMAIN_RE ")/users/(" ACCT_RE ")/statuses/(\\d+)", [](const httplib::Request& req, httplib::Response& res) {
using namespace std::string_literals;
serve_redirect(req, res, get_origin(req) + '/' + req.matches.str(1) + "/@" + req.matches.str(2) + '/' + req.matches.str(3), true);
});
serve_redirect(req, res, "/"s + req.matches.str(1) + "/@" + req.matches.str(2) + '/' + req.matches.str(3), true);
server.Get("/https://?(.+)", [](const httplib::Request& req, httplib::Response& res) {
serve_redirect(req, res, get_origin(req) + '/' + req.matches.str(1), true);
});
#ifndef NDEBUG