diff --git a/src/parsers/pipe.parser.ts b/src/parsers/pipe.parser.ts index 321418d..604f6fc 100644 --- a/src/parsers/pipe.parser.ts +++ b/src/parsers/pipe.parser.ts @@ -18,7 +18,7 @@ export class PipeParser extends AbstractTemplateParser implements ParserInterfac const regExp: RegExp = /(['"`])((?:(?!\1).|\\\1)+)\1\s*\|\s*translate/g; let matches: RegExpExecArray; while (matches = regExp.exec(template)) { - collection = collection.add(matches[2].replace('\\\'', '\'')); + collection = collection.add(matches[2].split('\\\'').join('\'')); } return collection; diff --git a/tests/parsers/pipe.parser.spec.ts b/tests/parsers/pipe.parser.spec.ts index 1d8a5e7..0926ffd 100644 --- a/tests/parsers/pipe.parser.spec.ts +++ b/tests/parsers/pipe.parser.spec.ts @@ -36,6 +36,12 @@ describe('PipeParser', () => { expect(keys).to.deep.equal([`World's largest potato`]); }); + it('should extract strings with multiple escaped quotes', () => { + const contents = `{{ 'C\\'est ok. C\\'est ok' | translate }}`; + const keys = parser.extract(contents, templateFilename).keys(); + expect(keys).to.deep.equal([`C'est ok. C'est ok`]); + }); + it('should extract interpolated strings using translate pipe in attributes', () => { const contents = ``; const keys = parser.extract(contents, templateFilename).keys();