File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
src/apps/review/src/lib/utils Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -112,9 +112,14 @@ export function findMetadataPhaseMatch(
112112 return { source : 'stringExact' }
113113 }
114114
115- const escapedTarget = escapeRegexLiteral ( target )
116- . replace ( / / g, '\\ ' )
117- const sepInsensitive = new RegExp ( `\\b${ escapedTarget . replace ( / \\ / g, '[-_\\s]+' ) } \\b` )
115+ // Replace all sequences of space, underscore, or hyphen in the target with a placeholder
116+ const WORDSEP_PLACEHOLDER = '__WORDSEP__'
117+ const sepPattern = / [ \- _ ] + / g
118+ const targetWithPlaceholder = target . replace ( sepPattern , WORDSEP_PLACEHOLDER )
119+ // Properly escape ALL regex metacharacters (including backslash), leaving the placeholder intact
120+ const escapedTarget = escapeRegexLiteral ( targetWithPlaceholder )
121+ . replace ( new RegExp ( escapeRegexLiteral ( WORDSEP_PLACEHOLDER ) , 'g' ) , '[-_\\s]+' )
122+ const sepInsensitive = new RegExp ( `\\b${ escapedTarget } \\b` )
118123 if ( sepInsensitive . test ( normalizedMetadata ) ) {
119124 return { source : 'stringBoundary' }
120125 }
You can’t perform that action at this time.
0 commit comments