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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

nain-F49FF806
Copy link

This is step one in addressing #360

Have modified the router slightly

  • If complete (including patch) version provided, forward as is
  • If only upto minor version is provided, redirect to patch zero of that minor version

This should help in redirecting minor version documentation access to (hopefully) valid pages

Todo/Future: Consider forwarding to latest patch when only minor version provided

- If complete (including patch) version provided, forward as is
- If only upto minor version is provided, redirect to patch zero of that minor version

Todo: Consider forwarding to latest patch when only minor version provided
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
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
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.

return callback(null, request);
}
// Include patch version 0 if only minor version is provided
// Todo("Forward to latest patch version if possible")
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if we can do this.
Asked in the original issue.
If we can't let's delete this line. 👍

return callback(null, request);
}
// Include patch version 0 if only minor version is provided
// Todo("Forward to latest patch version if possible")
const minor_versioned_pattern = /^(\d+)\.(\d+)\/(.*)/
Copy link
Member

Choose a reason for hiding this comment

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

This regex looks good 👍
image

@MarcoIeni
Copy link
Member

Looks great 🥳
Let me check if this is all that's required and I'll deploy it to the dev environment

return callback(null, request);
}
// Include patch version 0 if only minor version is provided
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// Include patch version 0 if only minor version is provided
// Include patch version 0 if minor version is provided

@MarcoIeni
Copy link
Member

Applied to dev-doc.rust-lang.org 👍
However https://dev-doc.rust-lang.org/1.65/std/boxed/struct.Box.html it's not working

@MarcoIeni
Copy link
Member

But https://dev-doc.rust-lang.org/1.65.0/std/boxed/struct.Box.html it's not working too.
let me check

@MarcoIeni
Copy link
Member

MarcoIeni commented Oct 9, 2024

I redeployed the master branch and apparently those URLs are not working in dev 🤔

I need to find a way to test this. 👀

@MarcoIeni
Copy link
Member

MarcoIeni commented Oct 9, 2024

Ok. Now https://dev-doc.rust-lang.org/1.65.0/std/boxed/struct.Box.html is working (the issue was my chache probably)

image

I will apply your changes again

@MarcoIeni
Copy link
Member

I applied your code and https://dev-doc.rust-lang.org/1.65/std/boxed/struct.Box.html isn't working.

Do you have any idea? Maybe the regex substitution doesn't work?

@nain-F49FF806
Copy link
Author

nain-F49FF806 commented Oct 9, 2024

I applied your code and https://dev-doc.rust-lang.org/1.65/std/boxed/struct.Box.html isn't working.

Do you have any idea? Maybe the regex substitution doesn't work?

Hi, I checked the request in browser's dev console.

image

I suspect the pattern has not matched due to the leading / indicating the root.
Have made a commit fixing the regex accordingly.

Could you try now?

p.s:
If the above is the correct reason why it didn't work then we may have to update the earlier regex also.
Have edited only one regex now so we can see if it works without changing behavior of the patch versioned case.

@MarcoIeni
Copy link
Member

MarcoIeni commented Oct 10, 2024

Deloyed 👍
https://dev-doc.rust-lang.org/1.65/std/boxed/struct.Box.html now works 🥳

I left some comments about the regex

@jdno
Copy link
Member

jdno commented Oct 10, 2024

This is something that I'd love to see added to our rust-lang/infra-smoke-tests. It will probably require creating a new TestSuite, so I'll try to create a tracking issue with some instructions later.

@MarcoIeni
Copy link
Member

MarcoIeni commented Oct 10, 2024

Looks great, I'm testing this one last time just to be sure 😂

EDIT: applied in dev again 👍 I'll wait a few minutes and see if it works. Let me know if it works for you.

Copy link
Member

@MarcoIeni MarcoIeni left a comment

Choose a reason for hiding this comment

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

This is working for me and the code looks good. 👍
Great job, thanks 🙌
I'll wait for a review from JD since CDN is quite critical.

@MarcoIeni MarcoIeni requested a review from jdno October 10, 2024 14:04
@MarcoIeni
Copy link
Member

One note for the maintainers: I want to merge this with "squash" strategy. Is that fine or do we want to the contributors to force push?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants