Skip to content

Commit

Permalink
Merge pull request #16 from vordgi/get-15
Browse files Browse the repository at this point in the history
get-15 fix get-params for optional catch-all routes
  • Loading branch information
vordgi authored Feb 18, 2024
2 parents fba27a6 + cd177a6 commit 6415dd3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package/src/get-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export const getParams = () => {

const isRootPage = cleanUrlPathname === '' && cleanPagePath === '';
const isNotFoundPage = pagePath.match(/\/_not-found\/?$/);
const isValidCatchALl = cleanPagePath.match(/\[\.\.\.[^\]]+\]/) && pathnameParts.length >= pagePathInterceptedParts.length;
const isCorrectMatched = isRootPage || isNotFoundPage || pagePathInterceptedParts.length === pathnameParts.length || isValidCatchALl;
const isValidCatchALl = cleanPagePath.match(/\/\[\.\.\.[^\]]+\]/) && pathnameParts.length >= pagePathInterceptedParts.length;
const isValidOptionalCatchALl = cleanPagePath.match(/\/\[\[\.\.\.[^\]]+\]\]/) && pathnameParts.length >= pagePathInterceptedParts.length - 1;
const isCorrectMatched = isRootPage || isNotFoundPage || pagePathInterceptedParts.length === pathnameParts.length || isValidCatchALl || isValidOptionalCatchALl;

if (!isCorrectMatched) {
const createIssueUrl = new URL('https://github.com/vordgi/next-impl-getters/issues/new')
Expand Down

0 comments on commit 6415dd3

Please sign in to comment.