From f838ffc762807fdab4eed74865d77ac8e711ca57 Mon Sep 17 00:00:00 2001 From: Michael Zangl Date: Fri, 7 Oct 2022 12:33:19 +0200 Subject: [PATCH] Ignore no requests if ignoreSuffix is empty (#94) An empty ignore suffix currently causes all requests to be ignored. This makes it impossible to disable ignoring by suffix. --- src/config/AgentConfig.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/config/AgentConfig.ts b/src/config/AgentConfig.ts index 8394a61..bda72f2 100644 --- a/src/config/AgentConfig.ts +++ b/src/config/AgentConfig.ts @@ -53,10 +53,19 @@ export function finalizeConfig(config: AgentConfig): void { 'i', ); - const ignoreSuffix = `^.+(?:${config - .ignoreSuffix!.split(',') - .map((s) => escapeRegExp(s.trim())) - .join('|')})$`; + const convertIgnoreSuffix = (configuredIgnoreSuffix: string | undefined) => { + if (!configuredIgnoreSuffix) { + // This regexp will never match => no files are ignored. + return '\\A(?!x)x'; + } else { + return `^.+(?:${configuredIgnoreSuffix! + .split(',') + .map((s) => escapeRegExp(s.trim())) + .join('|')})$`; + } + }; + + const ignoreSuffix = convertIgnoreSuffix(config.ignoreSuffix); const ignorePath = '^(?:' + config