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

Prevent /undefined catch-all routes in dev #4873

Merged
merged 1 commit into from Sep 26, 2022
Merged

Conversation

bluwy
Copy link
Member

@bluwy bluwy commented Sep 26, 2022

Changes

Fix #4796

In dev, for pages declared like pages/[...slug].astro, if slug is undefined, only serve at http://localhost:3000 and http://localhost:3000/. Don't serve http://localhost:3000/undefined

This PR makes undefined and "undefined" as 2 distinct static paths to differentiate them, by not stringifying undefined.

Note: In build, http://localhost:3000/undefined is never built. So this PR makes dev consistent with build.

Testing

Added a test under routing-priority

Docs

N/A.

@changeset-bot
Copy link

changeset-bot bot commented Sep 26, 2022

🦋 Changeset detected

Latest commit: 2c850c7

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Sep 26, 2022
Comment on lines -115 to -119

debug('findPathItemByKey', `Unexpected cache miss looking for ${paramsKey}`);
matchedStaticPath = staticPaths.find(
({ params: _params }) => JSON.stringify(_params) === paramsKey
);
Copy link
Member Author

Choose a reason for hiding this comment

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

This part of the code seems unused.

@matthewp matthewp merged commit 83ed1cc into main Sep 26, 2022
@matthewp matthewp deleted the undefined-catch-dev branch September 26, 2022 18:03
@astrobot-houston astrobot-houston mentioned this pull request Sep 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

getStaticPaths() with undefined slug creates actual "/undefined" route
2 participants