Skip to content

Commit de51c14

Browse files
fix: stop adding start/end chars to header patterns (#6547)
1 parent 18c4e2a commit de51c14

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

packages/edge-bundler/node/declaration.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,10 @@ export const getHeaderMatchers = (headers?: HeadersConfig): HeaderMatchers => {
194194
if (typeof headers[header] === 'boolean') {
195195
matchers[header] = { matcher: headers[header] ? 'exists' : 'missing' }
196196
} else if (typeof headers[header] === 'string') {
197-
matchers[header] = { matcher: 'regex', pattern: normalizePattern(headers[header]) }
197+
// Strip leading and forward slashes.
198+
const pattern = new RegExp(headers[header]).toString().slice(1, -1)
199+
200+
matchers[header] = { matcher: 'regex', pattern }
198201
} else {
199202
throw new BundleError(new Error(headerConfigError))
200203
}

packages/edge-bundler/node/manifest.test.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -620,9 +620,9 @@ describe('Header matching', () => {
620620
'x-present': true,
621621
'x-also-present': true,
622622
'x-absent': false,
623-
'x-match-prefix': '^prefix(.*)',
624-
'x-match-exact': 'exact',
625-
'x-match-suffix': '(.*)suffix$',
623+
'x-match-prefix': '^prefix',
624+
'x-match-exact': '^exact$',
625+
'x-match-suffix': 'suffix$',
626626
},
627627
},
628628
]
@@ -650,11 +650,11 @@ describe('Header matching', () => {
650650
matcher: 'regex',
651651
},
652652
'x-match-prefix': {
653-
pattern: '^prefix(.*)$',
653+
pattern: '^prefix',
654654
matcher: 'regex',
655655
},
656656
'x-match-suffix': {
657-
pattern: '^(.*)suffix$',
657+
pattern: 'suffix$',
658658
matcher: 'regex',
659659
},
660660
'x-present': {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy