diff --git a/terragrunt/modules/release-distribution/lambdas/doc-router/index.js b/terragrunt/modules/release-distribution/lambdas/doc-router/index.js index 34a65dc87..4b67701a8 100644 --- a/terragrunt/modules/release-distribution/lambdas/doc-router/index.js +++ b/terragrunt/modules/release-distribution/lambdas/doc-router/index.js @@ -66,10 +66,16 @@ exports.handler = (event, context, callback) => { return temp_redirect('https://www.rust-lang.org/learn', callback); } - // Forward versioned documentation as-is. - if (/^\/\d/.test(request.uri)) { + // Forward patch versioned documentation as-is. + if (/^\/(\d+)\.(\d+).(\d+)\/(.*)/.test(request.uri)) { return callback(null, request); } + // Include patch version 0 if minor versioned documentation is requested + const minor_versioned_pattern = /^\/(\d+)\.(\d+)\/(.*)/ + if (minor_versioned_pattern.test(request.uri)) { + const patched_uri = request.uri.replace(minor_versioned_pattern, "/$1.$2.0/$3"); + return temp_redirect(patched_uri, callback); + } for (let i = 0; i < CRATE_REDIRECTS.length; i++) { const crate = CRATE_REDIRECTS[i];