Skip to content

Commit a9d0321

Browse files
clydinalan-agius4
authored andcommitted
refactor(@angular-devkit/build-angular): reduce complexity of bundle budget threshold regex
The extra whitespace matching can be removed via a trim call prior to matching and casing can be handled by the `i` flag. (cherry picked from commit 271d561)
1 parent 9eb58cf commit a9d0321

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

packages/angular_devkit/build_angular/src/utils/bundle-calculator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ class AnyComponentStyleCalculator extends Calculator {
290290
* Calculate the bytes given a string value.
291291
*/
292292
function calculateBytes(input: string, baseline?: string, factor: 1 | -1 = 1): number {
293-
const matches = input.match(/^\s*(\d+(?:\.\d+)?)\s*(%|(?:[mM]|[kK]|[gG])?[bB])?\s*$/);
293+
const matches = input.trim().match(/^(\d+(?:\.\d+)?)[ \t]*(%|[kmg]?b)?$/i);
294294
if (!matches) {
295295
return NaN;
296296
}

0 commit comments

Comments
 (0)