Skip to content

Commit 0153314

Browse files
committed
fixup! refactor(@angular/pwa): minor refactorings to make code cleaner
1 parent 708717e commit 0153314

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

packages/angular/pwa/pwa/index.ts

+11-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,17 @@ function addServiceWorker(options: PwaOptions): Rule {
3737
}
3838

3939
function getIndent(text: string): string {
40-
// This RegExp is guaranteed to match any string (even if it is a zero-length match).
41-
return (/^ */.exec(text) as RegExpExecArray)[0];
40+
let indent = '';
41+
42+
for (const char of text) {
43+
if (char === ' ' || char === '\t') {
44+
indent += char;
45+
} else {
46+
break;
47+
}
48+
}
49+
50+
return indent;
4251
}
4352

4453
function updateIndexFile(options: PwaOptions): Rule {

0 commit comments

Comments
 (0)