Skip to content

Commit

Permalink
refactor: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Dec 9, 2024
1 parent 1ca2a13 commit 82da018
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 462 deletions.
194 changes: 0 additions & 194 deletions packages/router/src/new-route-resolver/matcher-pattern.ts

This file was deleted.

7 changes: 0 additions & 7 deletions packages/router/src/new-route-resolver/matcher.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, expect, it } from 'vitest'
import { MatcherPatternImpl } from './matcher-pattern'
import { createCompiledMatcher, NO_MATCH_LOCATION } from './matcher'
import {
MatcherPatternParams_Base,
Expand All @@ -10,12 +9,6 @@ import {
import { miss } from './matchers/errors'
import { EmptyParams } from './matcher-location'

function createMatcherPattern(
...args: ConstructorParameters<typeof MatcherPatternImpl>
) {
return new MatcherPatternImpl(...args)
}

const ANY_PATH_PATTERN_MATCHER: MatcherPatternPath<{ pathMatch: string }> = {
match(path) {
return { pathMatch: path }
Expand Down
52 changes: 15 additions & 37 deletions packages/router/src/new-route-resolver/matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,13 @@ import type {
MatcherPatternQuery,
} from './new-matcher-pattern'
import { warn } from '../warning'
import {
SLASH_RE,
encodePath,
encodeQueryValue as _encodeQueryValue,
} from '../encoding'
import { encodeQueryValue as _encodeQueryValue } from '../encoding'
import { parseURL, stringifyURL } from '../location'
import type {
MatcherLocationAsNamed,
MatcherLocationAsRelative,
MatcherParamsFormatted,
} from './matcher-location'
import { RouteRecordRaw } from 'test-dts'

/**
* Allowed types for a matcher name.
Expand Down Expand Up @@ -165,20 +160,20 @@ interface FnStableNull {
(value: string | number | null | undefined): string | null
}

function encodeParam(text: null | undefined, encodeSlash?: boolean): null
function encodeParam(text: string | number, encodeSlash?: boolean): string
function encodeParam(
text: string | number | null | undefined,
encodeSlash?: boolean
): string | null
function encodeParam(
text: string | number | null | undefined,
encodeSlash = true
): string | null {
if (text == null) return null
text = encodePath(text)
return encodeSlash ? text.replace(SLASH_RE, '%2F') : text
}
// function encodeParam(text: null | undefined, encodeSlash?: boolean): null
// function encodeParam(text: string | number, encodeSlash?: boolean): string
// function encodeParam(
// text: string | number | null | undefined,
// encodeSlash?: boolean
// ): string | null
// function encodeParam(
// text: string | number | null | undefined,
// encodeSlash = true
// ): string | null {
// if (text == null) return null
// text = encodePath(text)
// return encodeSlash ? text.replace(SLASH_RE, '%2F') : text
// }

// @ts-expect-error: overload are not correctly identified
const encodeQueryValue: FnStableNull =
Expand All @@ -190,23 +185,6 @@ const encodeQueryValue: FnStableNull =
// // for ts
// value => (value == null ? null : _encodeQueryKey(value))

function transformObject<T>(
fnKey: (value: string | number) => string,
fnValue: FnStableNull,
query: T
): T {
const encoded: any = {}

for (const key in query) {
const value = query[key]
encoded[fnKey(key)] = Array.isArray(value)
? value.map(fnValue)
: fnValue(value as string | number | null | undefined)
}

return encoded
}

export const NO_MATCH_LOCATION = {
name: __DEV__ ? Symbol('no-match') : Symbol(),
params: {},
Expand Down
48 changes: 0 additions & 48 deletions packages/router/src/new-route-resolver/matchers/path-param.ts

This file was deleted.

This file was deleted.

15 changes: 0 additions & 15 deletions packages/router/src/new-route-resolver/matchers/path-static.ts

This file was deleted.

Loading

0 comments on commit 82da018

Please sign in to comment.