From 8ef3050f1461bb824f095af5157624bfb68ef63c Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Thu, 28 Mar 2024 09:17:53 +0100 Subject: feat(cloudflare): major refactor for v10 (#159) Co-authored-by: Matthew Phillips <361671+matthewp@users.noreply.github.com> Co-authored-by: Emanuele Stoppa <602478+ematipico@users.noreply.github.com> Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com> Co-authored-by: Sarah Rainsberger --- .../cloudflare/src/utils/deduplicatePatterns.ts | 27 ---------------------- 1 file changed, 27 deletions(-) delete mode 100644 packages/integrations/cloudflare/src/utils/deduplicatePatterns.ts (limited to 'packages/integrations/cloudflare/src/utils/deduplicatePatterns.ts') diff --git a/packages/integrations/cloudflare/src/utils/deduplicatePatterns.ts b/packages/integrations/cloudflare/src/utils/deduplicatePatterns.ts deleted file mode 100644 index b408083ba..000000000 --- a/packages/integrations/cloudflare/src/utils/deduplicatePatterns.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Remove duplicates and redundant patterns from an `include` or `exclude` list. - * Otherwise Cloudflare will throw an error on deployment. Plus, it saves more entries. - * E.g. `['/foo/*', '/foo/*', '/foo/bar'] => ['/foo/*']` - * @param patterns a list of `include` or `exclude` patterns - * @returns a deduplicated list of patterns - */ -export function deduplicatePatterns(patterns: string[]) { - const openPatterns: RegExp[] = []; - - // A value in the set may only occur once; it is unique in the set's collection. - // ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set - const uniquePatterns = [...new Set(patterns)]; - for (const pattern of uniquePatterns) { - if (pattern.endsWith('*')) { - openPatterns.push(new RegExp(`^${pattern.replace(/(\*\/)*\*$/g, '(?=.{2,}).+[^*\n]$')}`)); - } - } - - return uniquePatterns - .sort((a, b) => a.length - b.length) - .filter((pattern) => { - if (openPatterns.some((p) => p.test(pattern))) return false; - - return true; - }); -} -- cgit v1.2.3