We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2600cc3 commit 443ea51Copy full SHA for 443ea51
packages/plugin-vue-jsx/src/filterUtils.ts
@@ -0,0 +1,23 @@
1
+export function exactRegex(input: string): RegExp {
2
+ return new RegExp(`^${escapeRegex(input)}$`)
3
+}
4
+
5
+const escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g
6
+function escapeRegex(str: string): string {
7
+ return str.replace(escapeRegexRE, '\\$&')
8
9
10
+export function matchWithQuery(input: string | RegExp): string | RegExp {
11
+ if (typeof input === 'string') {
12
+ return `${input}{?*,}`
13
+ }
14
+ return addQueryToRegex(input)
15
16
17
+function addQueryToRegex(input: RegExp) {
18
+ return new RegExp(
19
+ // replace `$` with `(?:\?.*)?$` (ignore `\$`)
20
+ input.source.replace(/(?<!\\)\$/g, '(?:\\?.*)?$'),
21
+ input.flags,
22
+ )
23
0 commit comments