diff --git a/data/redirects.yml b/data/redirects.yml index bb8112e92e80..8588f46720c6 100644 --- a/data/redirects.yml +++ b/data/redirects.yml @@ -8,6 +8,8 @@ # provide a short, permanent link to refer to a topic in the documentation. # For example, the docker CLI can output https://docs.docker.com/go/some-topic # in its help output, which can be redirected to elsewhere in the documentation. +"/learn/": + - /learn "/security/access-tokens/": - /go/access-tokens/ "/reference/api/engine/#deprecated-api-versions": diff --git a/hack/releaser/cloudfront-lambda-redirects.js b/hack/releaser/cloudfront-lambda-redirects.js index 6fbc40e5b182..0d0c472ed48d 100644 --- a/hack/releaser/cloudfront-lambda-redirects.js +++ b/hack/releaser/cloudfront-lambda-redirects.js @@ -8,7 +8,12 @@ exports.handler = (event, context, callback) => { const redirects = JSON.parse(`{{.RedirectsJSON}}`); for (let key in redirects) { const redirectTarget = key.replace(/\/$/, "") - if (redirectTarget !== requestUrl) { + const exactMatch = key === request.uri + // Preserve slash-insensitive matching without redirecting a canonical + // slash-terminated destination back to itself. + const normalizedMatch = redirectTarget === requestUrl && + redirects[key] !== request.uri + if (!exactMatch && !normalizedMatch) { continue; } //console.log(`redirect: ${requestUrl} to ${redirects[key]}`);