-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
(router): remove not-found param from web url on not found pages #25955
Conversation
Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
@@ -525,7 +525,8 @@ function getParamsWithConventionsCollapsed({ | |||
// Deep Dynamic Routes | |||
if (segments.some((segment) => segment.startsWith('*'))) { | |||
// NOTE(EvanBacon): Drop the param name matching the wildcard route name -- this is specific to Expo Router. | |||
const name = matchDeepDynamicRouteName(routeName) ?? routeName; | |||
const name = | |||
routeName === '+not-found' ? 'not-found' : matchDeepDynamicRouteName(routeName) ?? routeName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this work with nested not-found, e.g. foo/+not-found
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix this and updated the PR with extra tests.
I added a new matcher getPathnameWithParams
that allows you to assert what the pathname is with the query parameters.
@EvanBacon While working on this PR I noticed that global parameters for catchall routes where not being properly decoded. Currently the parameters for catch all routes are joined to a comma separated list. That was causing these new tests to fail I fixed the issue and updated the other affected tests. We had tests around this, but they were ineffective as they simply tested single values for catch all routes. I've updated these tests to use a variety of single and multiple values. |
…o#25955) # Why [ENG-10875](https://linear.app/expo/issue/ENG-10875) Remove the `not-found` param from web URLs # How When converting State->Path we use `matchDeepDynamicRouteName` to extract catch-all route param names, and ensure these are not serialised in the URL. While `+not-found` had the correct route pattern, our logic is going off the route name which does match the regex I added a special condition instead of updating the regex. https://github.com/expo/expo/blob/3e255470c5bff458883a75fe5b956d89147fa1b5/packages/expo-router/src/matchers.tsx#L9-L11 # Test Plan We had an existing test giving a false positive due to an incorrect pattern for the `+not-found` route # Checklist <!-- Please check the appropriate items below if they apply to your diff. This is required for changes to Expo modules. --> - [ ] Documentation is up to date to reflect these changes (eg: https://docs.expo.dev and README.md). - [ ] Conforms with the [Documentation Writing Style Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md) - [ ] This diff will work correctly for `npx expo prebuild` & EAS Build (eg: updated a module plugin). --------- Co-authored-by: Expo Bot <34669131+expo-bot@users.noreply.github.com>
Why
ENG-10875
Remove the
not-found
param from web URLsHow
When converting State->Path we use
matchDeepDynamicRouteName
to extract catch-all route param names, and ensure these are not serialised in the URL.While
+not-found
had the correct route pattern, our logic is going off the route name which does match the regexI added a special condition instead of updating the regex.
expo/packages/expo-router/src/matchers.tsx
Lines 9 to 11 in 3e25547
Test Plan
We had an existing test giving a false positive due to an incorrect pattern for the
+not-found
routeChecklist
npx expo prebuild
& EAS Build (eg: updated a module plugin).