-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7648075
commit 24dd4ac
Showing
2 changed files
with
47 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Resolve Route FullPath | ||
|
||
## Includes Query And Hash | ||
|
||
- Search Query: {{ JSON.stringify(resolveRoute('/?query=1')) }} | ||
- Hash: {{ JSON.stringify(resolveRoute('/#hash')) }} | ||
- Search Query And Hash: {{ JSON.stringify(resolveRoute('/?query=1#hash')) }} | ||
- Permalink And Search Query: {{ JSON.stringify(resolveRoute('/routes/permalinks/ascii-non-ascii.md?query=1')) }} | ||
|
||
<script setup> | ||
import { resolveRoute } from 'vuepress/client' | ||
</script> |
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,35 @@ | ||
import { expect, test } from '@playwright/test' | ||
|
||
const testCases = [ | ||
{ | ||
path: '/?query=1', | ||
notFound: false, | ||
}, | ||
{ | ||
path: '/#hash', | ||
notFound: false, | ||
}, | ||
{ | ||
path: '/?query=1#hash', | ||
notFound: false, | ||
}, | ||
{ | ||
path: encodeURI('/永久链接-ascii-中文/?query=1'), | ||
notFound: false, | ||
}, | ||
] | ||
|
||
test('should resolve routes when including both the query and hash', async ({ | ||
page, | ||
}) => { | ||
const listItemsLocator = await page | ||
.locator('.e2e-theme-content #includes-query-and-hash + ul > li') | ||
.all() | ||
|
||
for (const [index, li] of listItemsLocator.entries()) { | ||
const textContent = await li.textContent() | ||
const resolvedRoute = JSON.parse(/: (\{.*\})\s*$/.exec(textContent!)![1]) | ||
expect(resolvedRoute.path).toEqual(testCases[index].path) | ||
expect(resolvedRoute.notFound).toEqual(testCases[index].notFound) | ||
} | ||
}) |