Skip to content

Conversation

@mac-chaffee
Copy link
Contributor

@mac-chaffee mac-chaffee commented Oct 12, 2024

Hello! I'm a new (happy) Pico user who recently tried to set up a redirection for my pgs site like this: https://pico.sh/pgs#redirect-www-to-naked-domain

I found there was an off-by-one error in the parsing of _redirects files that caused the the destination path/URL must start with '/', 'http:' or 'https: validation to never trigger.

If there is no valid "To Part" in the string, but the "From Part" was valid, the previous code would use the "From Part" as the "To Part". For example, the version in the docs /* naked-domain.com 301 would be parsed as From: "/*" , To: "/*", Status: 301

The updated code throws an error, which I guess would become a 502 error. I've also updated the docs in another PR: picosh/docs#5

Copy link
Member

@neurosnap neurosnap left a comment

Choose a reason for hiding this comment

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

This looks great, thanks so much for your contribution!

@neurosnap neurosnap merged commit 7bf1673 into picosh:main Oct 13, 2024
@mac-chaffee
Copy link
Contributor Author

There's a chance that some silently-failing lines are hiding in existing _redirects files that might start suddenly breaking sites. If you have access, maybe checking existing usages would be wise

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.

2 participants