diff --git a/src/buildPronoun.ts b/src/buildPronoun.ts index cdbfd7781..3fcf7fbcb 100644 --- a/src/buildPronoun.ts +++ b/src/buildPronoun.ts @@ -66,6 +66,29 @@ const buildPronounFromTemplate = (key: string, template: PronounTemplate): Prono ); }; +const splitSlashes = (path: string): string[] => { + const chunks = []; + let escape = false; + let currentChunk = ''; + for (const character of path) { + if (escape) { + currentChunk += `\`${character}`; + escape = false; + } else { + if (character === '`') { + escape = true; + } else if (character === '/') { + chunks.push(currentChunk); + currentChunk = ''; + } else { + currentChunk += character; + } + } + } + chunks.push(currentChunk); + return chunks; +}; + const isModifier = (chunk: string, key: string, translator: Translator): boolean => { // use both locale and base translations to ensure backwards compatibility if key gets translated return chunk === `:${translator.translate(key)}` || chunk === `:${translator.get(key, false, true)}`; @@ -83,7 +106,7 @@ const extractModifierValue = (chunk: string, key: string, translator: Translator }; const buildPronounFromSlashes = (config: Config, path: string, translator: Translator): Pronoun | null => { - const chunks = path.split(/(?