From f5e76ae073e76f1581c776a593b4039eb913c1a3 Mon Sep 17 00:00:00 2001 From: Rhys Arkins <rhys@arkins.net> Date: Mon, 30 Dec 2019 09:12:04 +0000 Subject: [PATCH] fix: use re2 for packageRules --- lib/util/package-rules.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/util/package-rules.ts b/lib/util/package-rules.ts index 08d7dac9c4..a9e4171b5f 100644 --- a/lib/util/package-rules.ts +++ b/lib/util/package-rules.ts @@ -2,6 +2,7 @@ import minimatch from 'minimatch'; import { logger } from '../logger'; import * as versioning from '../versioning'; import { mergeChildConfig, PackageRule, UpdateType } from '../config'; +import { regEx } from './regex'; // TODO: move to `../config` export interface Config extends Record<string, any> { @@ -140,7 +141,7 @@ function matchesRule(inputConfig: Config, packageRule: PackageRule): boolean { // name match is "or" so we check patterns if we didn't match names if (!isMatch) { for (const packagePattern of packagePatterns) { - const packageRegex = new RegExp( + const packageRegex = regEx( packagePattern === '^*$' || packagePattern === '*' ? '.*' : packagePattern @@ -166,7 +167,7 @@ function matchesRule(inputConfig: Config, packageRule: PackageRule): boolean { if (excludePackagePatterns.length) { let isMatch = false; for (const pattern of excludePackagePatterns) { - const packageRegex = new RegExp( + const packageRegex = regEx( pattern === '^*$' || pattern === '*' ? '.*' : pattern ); if (depName && depName.match(packageRegex)) { -- GitLab