-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored route matching to include new logic for matching query
- Loading branch information
1 parent
2221550
commit e71e359
Showing
17 changed files
with
366 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { Resolved } from '@/types/resolved' | ||
import { Route } from '@/types/routes' | ||
|
||
export type RouteMatchRule = (route: Resolved<Route>, url: string) => boolean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
import { Route } from '@/types' | ||
import { Resolved } from '@/types/resolved' | ||
import { routeParamsAreValid } from '@/utilities/paramValidation' | ||
import { ResolvedWithRegex } from '@/utilities/resolveRoutesRegex' | ||
import { routePathMatches, routeQueryMatches } from '@/utilities/routeMatchRegexRules' | ||
|
||
export function routeMatch(routes: ResolvedWithRegex[], path: string): Resolved<Route> | undefined { | ||
const { route } = routes.find(({ regexp, route }) => { | ||
return regexp.test(path) && routeParamsAreValid(path, route) | ||
}) ?? {} | ||
export function routeMatch(routes: Resolved<Route>[], url: string): Resolved<Route> | undefined { | ||
const rules = [routePathMatches, routeQueryMatches, routeParamsAreValid] | ||
|
||
return route | ||
return routes.find(route => rules.every(test => test(route, url))) | ||
} |
Oops, something went wrong.