-
Notifications
You must be signed in to change notification settings - Fork 85
Prevent infinite redirect for doc-router /doc[^/]
#751
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
Conversation
I discovered this because someone else found this and posted about it, seemingly because they made a typo and forgot the URLs or something like that. |
thanks for this. The change itself looks good. Regarding the tests, can you document how to run them? |
There is a comment at the top of the tests that mentions it, just |
wait what that comment got lost, I'll add it |
It looks like my regression test for the issue also got lost, I'll need to redo that |
I converted the PR to draft so that it's clear that it's not ready to be reviewed yet 👍 |
d7ce21a
to
f4e93a0
Compare
Ah no, I did make a regression test, just not as part of the table tests. I squashed the comment fix I made earlier into the commit and it should be ready now. |
terragrunt/modules/release-distribution/lambdas/doc-router/test.mjs
Outdated
Show resolved
Hide resolved
terragrunt/modules/release-distribution/lambdas/doc-router/test.mjs
Outdated
Show resolved
Hide resolved
terragrunt/modules/release-distribution/lambdas/doc-router/test.mjs
Outdated
Show resolved
Hide resolved
terragrunt/modules/release-distribution/lambdas/doc-router/test.mjs
Outdated
Show resolved
Hide resolved
also it would be great if you could run the test in CI. |
f4e93a0
to
db10ba7
Compare
I updated the naming and added a new CI workflow based on the previous ones. It's hardly the greatest workflow but it just does the same as the existing ones. ...this test now fails though. it works for me locally. it looks like it redirects |
74ade05
to
2f50668
Compare
oh, this was changed on master and my branch was outdated! |
Previously, it would just put the slice in the Location with no regards for what was in there. If there was no slash after the `/doc`, it would issue a relative redirect, which was still under `/doc`, causing an infinite redirect. - /docs/std -> s/std - /docs/s/std -> s/s/std - /docs/s/s/s/std -> ... We prevent this behavior here by only applying the `/doc` redirect if there is a slash directly after it, causing the default /stable rewrite fallback to be applied to everything else, which will in practice lead to nice 404 page. This should not break anything as all such queries currently run into these loops, including plain `/doc`.
2f50668
to
395acf0
Compare
applied, thanks! |
Previously, it would just put the slice in the Location with no regards
for what was in there. If there was no slash after the
/doc
, it wouldissue a relative redirect, which was still under
/doc
, causing aninfinite redirect.
We prevent this behavior here by only applying the
/doc
redirect ifthere is a slash directly after it, causing the default /stable rewrite
fallback to be applied to everything else, which will in practice lead
to nice 404 page.
This should not break anything as all such queries currently run into
these loops, including plain
/doc
.Making a change to this core part of infrastructure that I can't reasonably test locally scared me, so I just wrote a bunch of unit tests for the thing.