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

🐛 fix redirects from draft gdoc deletion #3844

Merged
merged 1 commit into from
Aug 5, 2024
Merged

Conversation

ikesau
Copy link
Member

@ikesau ikesau commented Aug 5, 2024

Ensures we don't create redirects or trigger rebuilds for drafts, and that we never create redirects if the gdoc's full slug is /

@ikesau ikesau requested a review from marcelgerber August 5, 2024 13:55
@ikesau ikesau self-assigned this Aug 5, 2024
@owidbot
Copy link
Contributor

owidbot commented Aug 5, 2024

Quick links (staging server):

Site Admin Wizard

Login: ssh owid@staging-site-redirect-creation

SVG tester:

Number of differences (default views): 0 ✅
Number of differences (all views): 0 ✅

Edited: 2024-08-05 14:03:51 UTC
Execution time: 1.25 seconds

[getCanonicalUrl("", gdoc), "/"]
)
await triggerStaticBuild(res.locals.user, `Deleting ${gdoc.slug}`)
const gdocSlug = getCanonicalUrl("", gdoc)
Copy link
Member

Choose a reason for hiding this comment

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

So, if I see this correctly, if gdoc is a fragment then we'll end up with gdocSlug = "". We should explicitly handle that case, too - don't know what currently happens if we ever insert an empty string into the table.

Copy link
Member

Choose a reason for hiding this comment

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

Looking at it, it'll probably generate an incorrect redirect rule (something like / 302) which CF will then ignore. Still not great.

Copy link
Member Author

Choose a reason for hiding this comment

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

So rigorous! 😍

Went with a falsey check instead of an exception for type == Fragment 👍

@ikesau ikesau force-pushed the redirect-creation branch from f39934a to 75edba8 Compare August 5, 2024 14:52
@ikesau ikesau merged commit 5f7b971 into master Aug 5, 2024
20 checks passed
@ikesau ikesau deleted the redirect-creation branch August 5, 2024 23:00
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