aboutsummaryrefslogtreecommitdiffstats
path: root/lua/redirect_lower_url.lua
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2025-11-09 00:47:07 +0000
committersaturneric <[email protected]>2025-11-09 00:47:07 +0000
commit83adc475679ecf9078e72a8ecd48d4a224e0c964 (patch)
tree3cd86c22c568d9e0580116ad39832fd3cd5ca454 /lua/redirect_lower_url.lua
parentdocs(readme): improve setup and feature docs (diff)
downloadcgit-83adc475679ecf9078e72a8ecd48d4a224e0c964.tar.gz
cgit-83adc475679ecf9078e72a8ecd48d4a224e0c964.zip
refactor(config): simplify URL logic and remove Lua redirect
* Remove custom rewrite and Lua redirect for repo paths, standardizing URL handling in server config. * Update clone URLs to use an example domain. * Reduce enabled modules to only those required for serving and rewriting. * Streamline config to improve maintainability and reduce complexity.
Diffstat (limited to 'lua/redirect_lower_url.lua')
-rw-r--r--lua/redirect_lower_url.lua40
1 files changed, 0 insertions, 40 deletions
diff --git a/lua/redirect_lower_url.lua b/lua/redirect_lower_url.lua
deleted file mode 100644
index 5aae177..0000000
--- a/lua/redirect_lower_url.lua
+++ /dev/null
@@ -1,40 +0,0 @@
--- /usr/lib/cgit/lua/debug_gpgfrontend.lua
-local r = lighty.r
-local a = r.req_attr
-
--- Get the original path
-local raw = a["uri.path-raw"] or a["uri.path"] or "/"
-local orig = a["request.orig-uri"] or raw
-
--- Target path
-local new_path
-
--- 1) /GpgFrontend/... → /gpgfrontend/...
-if orig:match("^/GpgFrontend") then
- new_path = orig:gsub("^/GpgFrontend", "/gpgfrontend")
--- 2) /cgit.cgi/GpgFrontend/... → /gpgfrontend/... (let rewrite add /cgit.cgi once)
-elseif orig:match("^/cgit%.cgi/GpgFrontend") then
- new_path = orig:gsub("^/cgit%.cgi/GpgFrontend", "/gpgfrontend")
-end
-
--- If rule matches, convert repo name to lowercase
-if new_path then
- -- Capture repo segment: /gpgfrontend/<repo>/...
- new_path = new_path:gsub("^(/gpgfrontend/)([^/]+)",
- function(prefix, repo)
- return prefix .. repo:lower()
- end)
-
- -- Append query string
- local q = a["uri.query"]
- if q and #q > 0 and not new_path:find("%?") then
- new_path = new_path .. "?" .. q
- end
-
- r.resp_header["Location"] = new_path
- return 301
-end
-
--- Visible marker
-r.resp_header["X-Magnet-Probed"] = "1"
-return 0 \ No newline at end of file