Files
ngx-translate-extract/src/utils/utils.ts
Kim Biesbjerg 73877a5a35 Add stripBOM
2019-07-08 15:13:07 +02:00

23 lines
548 B
TypeScript

/**
* Assumes file is an Angular component if type is javascript/typescript
*/
export function isPathAngularComponent(path: string): boolean {
return (/\.ts|js$/i).test(path);
}
/**
* Extract inline template from a component
*/
export function extractComponentInlineTemplate(contents: string): string {
const regExp: RegExp = /template\s*:\s*(["'`])([^\1]*?)\1/;
const match = regExp.exec(contents);
if (match !== null) {
return match[2];
}
return '';
}
export function stripBOM(contents: string): string {
return contents.trim();
}