diff options
| author | Stanisław Zagórowski <hasohasacz@gmail.com> | 2024-01-29 17:29:07 +0100 |
|---|---|---|
| committer | Stanisław Zagórowski <hasohasacz@gmail.com> | 2024-01-29 17:29:07 +0100 |
| commit | 3cf21a28f3c64b69e10dec76869f23e7d0bd7933 (patch) | |
| tree | 7d626cade0b57b8cbd6ece0da06ee39611d6dac7 /reluax.luax | |
| parent | 35d76e1b92692398ed61caef819b678477204989 (diff) | |
site: simplify redirects
Diffstat (limited to 'reluax.luax')
| -rw-r--r-- | reluax.luax | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/reluax.luax b/reluax.luax index 034d408..5b05eb7 100644 --- a/reluax.luax +++ b/reluax.luax @@ -15,11 +15,6 @@ local blogposts = require("blog.posts") math.randomseed(os.time()) -local redirects = { - { slug = "mrfinalboss", url = "https://jellingfish-games.itch.io/mr-final-boss" }, - { slug = "bumblingbuilders", url = "https://oroshibu.itch.io/bumbling-builders" } -} - local wrap_component = function(component) return <Common> @@ -33,6 +28,11 @@ local wrap_component = function(component) </Common> end +local redirects = { + ["mrfinalboss"] = "https://jellingfish-games.itch.io/mr-final-boss", + ["bumblingbuilders"] = "https://oroshibu.itch.io/bumbling-builders" +} + local route = function(path, method, headers, body) if method ~= 'GET' then return 405, "Method not allowed" @@ -40,16 +40,10 @@ local route = function(path, method, headers, body) if reluax.url_matches('/r/{slug}', path) then local slug = reluax.url_extract('/r/{slug}', path).slug - local redirect = nil - for _, r in ipairs(redirects) do - if r.slug == slug then - redirect = r - break - end - end + local redirect = redirects[slug] if redirect then local headers = { - ["Location"] = redirect.url + ["Location"] = redirect } local body = <a>You are being redirected...</a> return 301, reluax.headers(body, headers) |
