From e31cd4e9be822752dbf72a2a4e8bd2553598f8b4 Mon Sep 17 00:00:00 2001 From: blankie Date: Fri, 24 Nov 2023 10:59:22 +1100 Subject: [PATCH] Redirect /https://... to /... --- main.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.cpp b/main.cpp index 70bdd75..86726cc 100644 --- a/main.cpp +++ b/main.cpp @@ -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