Skip to content

Commit 38f7857

Browse files
committed
fix: default match rules
1 parent c03a7c4 commit 38f7857

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

core/router.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,10 @@ export class CreateHistory<RN extends RouteName, FieldsMeta = MetaValue> {
3636
#withPattern = computed(() =>
3737
mapValues<Data<RN, FieldsMeta>, RouteWithPatternValue<FieldsMeta>>(
3838
this.#routeData.value,
39-
({ pathname, hash = '', search = '', normalize = true, ...rest }) => {
39+
({ pathname, hash, search, normalize = true, ...rest }) => {
4040
const patternOptions = { hash, search, pathname }
4141

4242
if (normalize) {
43-
patternOptions.hash = hash || '*'
44-
patternOptions.search = search || '*'
45-
4643
if (!trailingSlash.matchAny(pathname)) {
4744
patternOptions.pathname = `${pathname}{/}?`
4845
}

core/types.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ export type RouteName = string
99
/** Default value */
1010
export type MetaValue = unknown
1111

12-
type PatternFields = Pick<URLPattern, 'pathname' | 'search' | 'hash'>
12+
type OptionalPatternFields = Partial<Pick<URLPattern, 'search' | 'hash'>>
13+
type RequiredPatternFields = Pick<URLPattern, 'pathname'>
14+
type PatternFields = OptionalPatternFields & RequiredPatternFields
1315

1416
type Fields<Meta extends MetaValue> = {
1517
/**

0 commit comments

Comments
 (0)