forked from vitejs/vite
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
query.ts
37 lines (36 loc) · 738 Bytes
/
query.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
export interface VueQuery {
vue?: boolean
src?: string
type?: 'script' | 'template' | 'style' | 'custom'
index?: number
lang?: string
raw?: boolean
url?: boolean
scoped?: boolean
}
export function parseVueRequest(id: string): {
filename: string
query: VueQuery
} {
const [filename, rawQuery] = id.split(`?`, 2)
const query = Object.fromEntries(new URLSearchParams(rawQuery)) as VueQuery
if (query.vue != null) {
query.vue = true
}
if (query.index != null) {
query.index = Number(query.index)
}
if (query.raw != null) {
query.raw = true
}
if (query.url != null) {
query.url = true
}
if (query.scoped != null) {
query.scoped = true
}
return {
filename,
query
}
}