Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure patch version is provided if accessing versioned documentation #612

Merged
merged 2 commits into from
Nov 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Temp redirect is used so the patch version used can be updated later.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we want to update it later? 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in case we could update the code to get the latest patch live and direct to it.
If we can then temp redirect would be good, as the latest patch version for a minor release can change.

If we are happy with always redirecting to the patch zero release. Then regular redirect should do.

}

for (let i = 0; i < CRATE_REDIRECTS.length; i++) {
const crate = CRATE_REDIRECTS[i];
Expand Down
Loading