Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/composables/useMarkdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,8 @@ function stripAndEscapeHtml(text: string, packageName?: string): string {
stripped = stripped.trim()
// Collapse multiple whitespace into single space
stripped = stripped.replace(/\s+/g, ' ')
// Escape special regex characters in package name
const escapedName = packageName.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
// Match package name at the start, optionally followed by: space, dash, colon, hyphen, or just space
const namePattern = new RegExp(`^${escapedName}\\s*[-:—]?\\s*`, 'i')
const namePattern = new RegExp(`^${RegExp.escape(packageName)}\\s*[-:—]?\\s*`, 'i')
stripped = stripped.replace(namePattern, '').trim()
}

Expand Down
4 changes: 3 additions & 1 deletion app/composables/useStructuredFilters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,9 @@ export function useStructuredFilters(options: UseStructuredFiltersOptions) {

function removeKeyword(keyword: string) {
filters.value.keywords = filters.value.keywords.filter(k => k !== keyword)
const newQ = searchQuery.value.replace(new RegExp(`keyword:${keyword}($| )`, 'g'), '').trim()
const newQ = searchQuery.value
.replace(new RegExp(`keyword:${RegExp.escape(keyword)}($| )`, 'g'), '')
.trim()
router.replace({ query: { ...route.query, q: newQ || undefined } })
if (searchQueryModel) searchQueryModel.value = newQ
}
Expand Down
9 changes: 9 additions & 0 deletions global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
declare global {
interface RegExpConstructor {
escape(str: string): string
}
}

// required for the global type to work
// oxlint-disable-next-line eslint-plugin-unicorn(require-module-specifiers)
export {}
Comment thread
ghostdevv marked this conversation as resolved.
Outdated
1 change: 1 addition & 0 deletions knip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const config: KnipConfig = {
'h3-next',
],
ignoreUnresolved: ['#components', '#oauth/config'],
ignoreFiles: ['global.d.ts'],
Comment thread
ghostdevv marked this conversation as resolved.
Outdated
},
'cli': {
project: ['src/**/*.ts!', '!src/mock-*.ts'],
Expand Down
8 changes: 4 additions & 4 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export default defineNuxtConfig({
},
typescript: {
tsConfig: {
include: ['../test/unit/server/**/*.ts'],
include: ['../test/unit/server/**/*.ts', '../global.d.ts'],
},
},
},
Expand Down Expand Up @@ -287,10 +287,10 @@ export default defineNuxtConfig({
'#cli/*': ['../cli/src/*'],
},
},
include: ['../test/unit/app/**/*.ts'],
include: ['../test/unit/app/**/*.ts', '../global.d.ts'],
},
sharedTsConfig: {
include: ['../test/unit/shared/**/*.ts'],
include: ['../test/unit/shared/**/*.ts', '../global.d.ts'],
},
nodeTsConfig: {
compilerOptions: {
Expand All @@ -301,7 +301,7 @@ export default defineNuxtConfig({
'#shared/*': ['../shared/*'],
},
},
include: ['../*.ts', '../test/e2e/**/*.ts'],
include: ['../*.ts', '../test/e2e/**/*.ts', '../global.d.ts'],
},
},

Expand Down
2 changes: 1 addition & 1 deletion shared/utils/emoji.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ const emojis = {

const emojisKeysRegex = new RegExp(
Object.keys(emojis)
.map(key => `:${key}:`)
.map(key => `:${RegExp.escape(key)}:`)
.join('|'),
'g',
)
Expand Down
Loading