hugo-wasm/config
Bjørn Erik Pedersen 029d1e0ced Add some more server options/improvements
New options:

* `FromHeaders`: Server header matching for redirects
* `FromRe`: Regexp with group support, i.e. it replaces $1, $2 in To with the group matches.

Note that if both `From` and `FromRe` is set, both must match.

Also

* Allow redirects to non HTML URLs as long as the Sec-Fetch-Mode is set to navigate on the request.
* Detect and stop redirect loops.

This was all done while testing out InertiaJS with Hugo. So, after this commit, this setup will support the main parts of the protocol that Inertia uses:

```toml
[server]
    [[server.headers]]
        for = '/**/inertia.json'
        [server.headers.values]
            Content-Type = 'text/html'
            X-Inertia    = 'true'
            Vary         = 'Accept'

    [[server.redirects]]
        force       = true
        from        = '/**/'
        fromRe      = "^/(.*)/$"
        fromHeaders = { "X-Inertia" = "true" }
        status      = 301
        to          = '/$1/inertia.json'
```

Unfortunately, a provider like Netlify does not support redirects matching by request headers. It should be possible with some edge function, but then again, I'm not sure that InertiaJS is a very good fit with the common Hugo use cases.

But this commit should be generally useful.
2025-02-05 18:14:15 +01:00
..
allconfig Make cascade front matter order deterministic 2025-01-23 09:45:47 +01:00
privacy tpl/tplimpl: Deprecate twitter shortcode in favor of x shortcode 2025-01-16 10:33:34 +01:00
security deps: Upgrade github.com/bep/gitmap v1.4.0 => v1.6.0 (note) 2024-07-17 10:54:28 +02:00
services tpl/tplimpl: Deprecate twitter shortcode in favor of x shortcode 2025-01-16 10:33:34 +01:00
testconfig all: Rework page store, add a dynacache, improve partial rebuilds, and some general spring cleaning 2024-01-27 16:28:14 +01:00
commonConfig.go Add some more server options/improvements 2025-02-05 18:14:15 +01:00
commonConfig_test.go Add some more server options/improvements 2025-02-05 18:14:15 +01:00
configLoader.go all: Run gofumpt -l -w . 2024-01-28 23:14:09 +01:00
configLoader_test.go tests: Convert from testify to quicktest 2019-08-12 13:26:32 +02:00
configProvider.go Add js.Batch 2024-12-12 21:43:17 +01:00
configProvider_test.go Misc config loading fixes 2021-06-14 17:00:32 +02:00
defaultConfigProvider.go all: Run gofumpt -l -w . 2024-01-28 23:14:09 +01:00
defaultConfigProvider_test.go all: gofmt -w -r 'interface{} -> any' . 2022-03-17 22:03:27 +01:00
env.go all: Run gofumpt -l -w . 2024-01-28 23:14:09 +01:00
env_test.go tests: Convert from testify to quicktest 2019-08-12 13:26:32 +02:00
namespace.go resources: Fix 2 image file cache key issues 2025-01-18 12:23:18 +01:00
namespace_test.go resources: Fix 2 image file cache key issues 2025-01-18 12:23:18 +01:00