Skip to content

Commit 51be2ae

Browse files
committed
refactor: update to use @li/regexp-escape-polyfill
1 parent 4454fa9 commit 51be2ae

File tree

8 files changed

+18
-17
lines changed

8 files changed

+18
-17
lines changed

app/composables/useMarkdown.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { regExpEscape } from '@li/regexp-escape-polyfill'
12
import { decodeHtmlEntities } from '~/utils/formatters'
23

34
interface UseMarkdownOptions {
@@ -46,7 +47,7 @@ function stripAndEscapeHtml(text: string, packageName?: string): string {
4647
// Collapse multiple whitespace into single space
4748
stripped = stripped.replace(/\s+/g, ' ')
4849
// Match package name at the start, optionally followed by: space, dash, colon, hyphen, or just space
49-
const namePattern = new RegExp(`^${RegExp.escape(packageName)}\\s*[-:—]?\\s*`, 'i')
50+
const namePattern = new RegExp(`^${regExpEscape(packageName)}\\s*[-:—]?\\s*`, 'i')
5051
stripped = stripped.replace(namePattern, '').trim()
5152
}
5253

app/composables/useStructuredFilters.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
parseSortOption,
1818
UPDATED_WITHIN_OPTIONS,
1919
} from '#shared/types/preferences'
20+
import { regExpEscape } from '@li/regexp-escape-polyfill'
2021

2122
/**
2223
* Parsed search operators from text input
@@ -413,7 +414,7 @@ export function useStructuredFilters(options: UseStructuredFiltersOptions) {
413414
function removeKeyword(keyword: string) {
414415
filters.value.keywords = filters.value.keywords.filter(k => k !== keyword)
415416
const newQ = searchQuery.value
416-
.replace(new RegExp(`keyword:${RegExp.escape(keyword)}($| )`, 'g'), '')
417+
.replace(new RegExp(`keyword:${regExpEscape(keyword)}($| )`, 'g'), '')
417418
.trim()
418419
router.replace({ query: { ...route.query, q: newQ || undefined } })
419420
if (searchQueryModel) searchQueryModel.value = newQ

global.d.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

knip.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ const config: KnipConfig = {
5555
'h3-next',
5656
],
5757
ignoreUnresolved: ['#components', '#oauth/config'],
58-
ignoreFiles: ['global.d.ts'],
5958
},
6059
'cli': {
6160
project: ['src/**/*.ts!', '!src/mock-*.ts'],

nuxt.config.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ export default defineNuxtConfig({
203203
},
204204
typescript: {
205205
tsConfig: {
206-
include: ['../test/unit/server/**/*.ts', '../global.d.ts'],
206+
include: ['../test/unit/server/**/*.ts'],
207207
},
208208
},
209209
},
@@ -287,10 +287,10 @@ export default defineNuxtConfig({
287287
'#cli/*': ['../cli/src/*'],
288288
},
289289
},
290-
include: ['../test/unit/app/**/*.ts', '../global.d.ts'],
290+
include: ['../test/unit/app/**/*.ts'],
291291
},
292292
sharedTsConfig: {
293-
include: ['../test/unit/shared/**/*.ts', '../global.d.ts'],
293+
include: ['../test/unit/shared/**/*.ts'],
294294
},
295295
nodeTsConfig: {
296296
compilerOptions: {
@@ -301,7 +301,7 @@ export default defineNuxtConfig({
301301
'#shared/*': ['../shared/*'],
302302
},
303303
},
304-
include: ['../*.ts', '../test/e2e/**/*.ts', '../global.d.ts'],
304+
include: ['../*.ts', '../test/e2e/**/*.ts'],
305305
},
306306
},
307307

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"@iconify-json/svg-spinners": "1.2.4",
6161
"@iconify-json/vscode-icons": "1.2.40",
6262
"@intlify/shared": "11.2.8",
63+
"@li/regexp-escape-polyfill": "jsr:0.3.4",
6364
"@lunariajs/core": "https://pkg.pr.new/lunariajs/lunaria/@lunariajs/core@f07e1a3",
6465
"@nuxt/a11y": "1.0.0-alpha.1",
6566
"@nuxt/fonts": "0.13.0",

pnpm-lock.yaml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

shared/utils/emoji.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1907,7 +1907,7 @@ const emojis = {
19071907

19081908
const emojisKeysRegex = new RegExp(
19091909
Object.keys(emojis)
1910-
.map(key => `:${RegExp.escape(key)}:`)
1910+
.map(key => `:${key}:`)
19111911
.join('|'),
19121912
'g',
19131913
)

0 commit comments

Comments
 (0)