Make regexes more readable by not creating from string
This commit is contained in:
parent
fdf26d6af5
commit
3601b5985b
@ -5,14 +5,14 @@ export abstract class AbstractTemplateParser {
|
||||
* makes the assumption that it is an Angular Component
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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) {
|
||||
return match[2];
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ export class PipeParser extends AbstractTemplateParser implements ParserInterfac
|
||||
protected _parseTemplate(template: string): 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;
|
||||
while (matches = regExp.exec(template)) {
|
||||
|
Loading…
Reference in New Issue
Block a user