Skip to content

Commit

Permalink
Backported undefined url param error from next
Browse files Browse the repository at this point in the history
  • Loading branch information
jsimck committed Mar 6, 2023
1 parent b4e7bad commit e0708dd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/ten-frogs-smoke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ima/core": patch
---

Backport fix from `next` - for missing optional parameters in static router that are evaluated as 'undefined' instead of undefined.
2 changes: 1 addition & 1 deletion packages/core/src/router/StaticRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ export default class StaticRoute extends AbstractRoute {

if (currentCoreName) {
const value = AbstractRoute.decodeURIParameter(rawValue) as string;
parameters[currentCoreName] = value;
parameters[currentCoreName] = rawValue ? value : rawValue;
}
}

Expand Down
5 changes: 5 additions & 0 deletions packages/core/src/router/__tests__/StaticRouteSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -806,6 +806,11 @@ describe('ima.core.router.StaticRoute', function () {
path: '/something/param1/user1',
params: {},
},
{
pathExpression: '/test/:?param1/:?param2',
path: '/test/xxx',
params: { param1: 'xxx', param2: undefined },
},
].forEach(value => {
it(value.pathExpression, function () {
const localStaticRoute = new StaticRoute(
Expand Down

0 comments on commit e0708dd

Please sign in to comment.