Skip to content

Commit 644ba18

Browse files
committed
use matchProtocol when parsing the protocol in validate-headers.ts
1 parent 07f6610 commit 644ba18

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

.changeset/silent-dragons-jam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
Update validate-headers to use matchProtocol when parsing protocol

packages/astro/src/core/app/validate-headers.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { matchPattern, type RemotePattern } from '@astrojs/internal-helpers/remote';
1+
import { matchPattern, matchProtocol, type RemotePattern } from '@astrojs/internal-helpers/remote';
22

33
/**
44
* Sanitize a hostname by rejecting any with path separators.
@@ -93,7 +93,7 @@ export function validateForwardedHeaders(
9393
// Validate against allowedDomains patterns
9494
try {
9595
const testUrl = new URL(`${forwardedProtocol}://example.com`);
96-
const isAllowed = allowedDomains.some((pattern) => matchPattern(testUrl, pattern));
96+
const isAllowed = allowedDomains.some((pattern) => matchProtocol(testUrl, pattern.protocol));
9797
if (isAllowed) {
9898
result.protocol = forwardedProtocol;
9999
}

0 commit comments

Comments
 (0)