Replace all occurences of escaped quotes.
This commit is contained in:
		| @@ -18,7 +18,7 @@ export class PipeParser extends AbstractTemplateParser implements ParserInterfac | |||||||
| 		const regExp: RegExp = /(['"`])((?:(?!\1).|\\\1)+)\1\s*\|\s*translate/g; | 		const regExp: RegExp = /(['"`])((?:(?!\1).|\\\1)+)\1\s*\|\s*translate/g; | ||||||
| 		let matches: RegExpExecArray; | 		let matches: RegExpExecArray; | ||||||
| 		while (matches = regExp.exec(template)) { | 		while (matches = regExp.exec(template)) { | ||||||
| 			collection = collection.add(matches[2].replace('\\\'', '\'')); | 			collection = collection.add(matches[2].split('\\\'').join('\'')); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		return collection; | 		return collection; | ||||||
|   | |||||||
| @@ -36,6 +36,12 @@ describe('PipeParser', () => { | |||||||
| 		expect(keys).to.deep.equal([`World's largest potato`]); | 		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', () => { | 	it('should extract interpolated strings using translate pipe in attributes', () => { | ||||||
| 		const contents = `<span attr="{{ 'Hello World' | translate }}"></span>`; | 		const contents = `<span attr="{{ 'Hello World' | translate }}"></span>`; | ||||||
| 		const keys = parser.extract(contents, templateFilename).keys(); | 		const keys = parser.extract(contents, templateFilename).keys(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user