Skip to content

Commit

Permalink
chore: rename new methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope committed May 22, 2024
1 parent 31ac4c9 commit 46bd7ba
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions packages/client/src/router/resolveRoute.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolveRoutePathInfo } from '@vuepress/shared'
import { resolvePathInfo } from '@vuepress/shared'
import { routes } from '../internal/routes.js'
import type { Route, RouteMeta } from '../types/index.js'
import { resolveRoutePath } from './resolveRoutePath.js'
Expand All @@ -17,7 +17,7 @@ export const resolveRoute = <T extends RouteMeta = RouteMeta>(
currentPath?: string,
): ResolvedRoute<T> => {
// get only the pathname from the path
const [pathname, hashAndQueries] = resolveRoutePathInfo(path)
const [pathname, hashAndQueries] = resolvePathInfo(path)

// resolve the route path
const routePath = resolveRoutePath(pathname, currentPath)
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/router/resolveRouteFullPath.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolveRoutePathInfo } from '@vuepress/shared'
import { resolvePathInfo } from '@vuepress/shared'
import { resolveRoutePath } from './resolveRoutePath.js'

/**
Expand All @@ -8,7 +8,7 @@ export const resolveRouteFullPath = (
path: string,
currentPath?: string,
): string => {
const [pathname, hashAndQueries] = resolveRoutePathInfo(path)
const [pathname, hashAndQueries] = resolvePathInfo(path)

return resolveRoutePath(pathname, currentPath) + hashAndQueries
}
2 changes: 1 addition & 1 deletion packages/shared/src/utils/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from './inferRoutePath'
export * from './normalizeRoutePath.js'
export * from './resolveLocalePath.js'
export * from './resolveRoutePathFromUrl.js'
export * from './resolveRoutePathInfo.js'
export * from './resolvePathInfo.js'
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
const SPLIT_CHAR_REGEXP = /(#|\?)/

/**
* Extract pathname / hash and queries from a full route path
* Extract pathname / hash and queries from a relative URL
*/
export const resolveRoutePathInfo = (
export const resolvePathInfo = (
path: string,
): [pathname: string, hashAndQueries: string] => {
const [pathname, ...hashAndQueries] = path.split(SPLIT_CHAR_REGEXP)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, expect, it } from 'vitest'
import { resolveRoutePathInfo } from '../../src/index.js'
import { resolvePathInfo } from '../../src/index.js'

const testCases: [string, [string, string]][] = [
['/a/b/c/', ['/a/b/c/', '']],
Expand All @@ -12,10 +12,10 @@ const testCases: [string, [string, string]][] = [
['/a/index.html?a=1#b', ['/a/index.html', '?a=1#b']],
]

describe('should resolve route path info correctly', () => {
describe('should resolve path info correctly', () => {
testCases.forEach(([source, expected]) => {
it(`${source} -> ${expected}`, () => {
expect(resolveRoutePathInfo(source)).toEqual(expected)
expect(resolvePathInfo(source)).toEqual(expected)
})
})
})

0 comments on commit 46bd7ba

Please sign in to comment.