diff --git a/src/stores/target_store.ts b/src/stores/target_store.ts index 91290c9..fa7ee16 100644 --- a/src/stores/target_store.ts +++ b/src/stores/target_store.ts @@ -210,12 +210,27 @@ export class TargetStore { // note: the multiple slash escaping is due to all the layers between this code and the CODAP formula evaluator const escapedText = text .replace(/[.*+?^${}()|[\]\\]/g, '\\\\\\\\$&') // escape regex modifiers - .replace(/\s+/g, '\\\\\\\\s+'); // allow multiple spaces between words + .replace(/\s+/g, '\\\\\\\\s+') // allow multiple spaces between words + .replace(/['"“”‘’]/g, (match) => { // allow both regular and smart quotes to match each other + switch (match) { + case '"': + case '“': + case '”': + return `["“”]`; + case "'": + case '‘': + case '’': + return `['‘’]`; + default: + return match; + } + }); // don't add word boundaries when the user input starts/ends with non-word characters, like ! or , as that would fail matching const wordBoundary = `\\\\\\\\b`; const maybeStartingWordBoundary = /^\w/.test(text) ? wordBoundary : ''; const maybeEndingWordBoundary = /\w$/.test(text) ? wordBoundary : ''; const tParamString = `${tTargetAttr},"${tBegins}${maybeStartingWordBoundary}${escapedText}${maybeEndingWordBoundary}${tEnds}"`; + console.log("tParamString", tParamString); let tResult = ''; switch (option) {//['contain', 'not contain', 'start with', 'end with'] case featureDescriptors.containsOptions[0]: // contain