Make regexes more readable by not creating from string
This commit is contained in:
		| @@ -5,14 +5,14 @@ export abstract class AbstractTemplateParser { | |||||||
| 	 * makes the assumption that it is an Angular Component | 	 * makes the assumption that it is an Angular Component | ||||||
| 	 */ | 	 */ | ||||||
| 	protected _isAngularComponent(filePath: string): boolean { | 	protected _isAngularComponent(filePath: string): boolean { | ||||||
| 		return new RegExp('\.(ts|js)$', 'i').test(filePath); | 		return new RegExp(/\.(ts|js)$/, 'i').test(filePath); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	/** | 	/** | ||||||
| 	 * Extracts inline template from components | 	 * Extracts inline template from components | ||||||
| 	 */ | 	 */ | ||||||
| 	protected _extractInlineTemplate(contents: string): string { | 	protected _extractInlineTemplate(contents: string): string { | ||||||
| 		const match = new RegExp('template\\s?:\\s?("|\'|`)((.|[\\r\\n])+?[^\\\\])\\1').exec(contents); | 		const match = new RegExp(/template\s?:\s?("|\'|`)((.|[\r\n])+?[^\\])\1/).exec(contents); | ||||||
| 		if (match !== null) { | 		if (match !== null) { | ||||||
| 			return match[2]; | 			return match[2]; | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ export class PipeParser extends AbstractTemplateParser implements ParserInterfac | |||||||
| 	protected _parseTemplate(template: string): string[] { | 	protected _parseTemplate(template: string): string[] { | ||||||
| 		let results: string[] = []; | 		let results: string[] = []; | ||||||
|  |  | ||||||
| 		const regExp = new RegExp('([\'"`])([^\\1\\r\\n]*)\\1\\s+\\|\\s*translate(:.*?)?', 'g'); | 		const regExp = new RegExp(/([\'"`])([^\1\r\n]*)\1\s+\|\s*translate(:.*?)?/, 'g'); | ||||||
|  |  | ||||||
| 		let matches; | 		let matches; | ||||||
| 		while (matches = regExp.exec(template)) { | 		while (matches = regExp.exec(template)) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user