feat: add ensurePeered() core function with race deduplication

This commit is contained in:
Jannis Braun
2026-04-09 13:40:49 +02:00
parent abd12223b1
commit f802528688
3 changed files with 216 additions and 1 deletions
+1 -1
View File
@@ -73,7 +73,7 @@ function resolveLocalOrigin(request: { headers: Record<string, string | string[]
* Validate that a string is a well-formed HTTP(S) URL origin.
* Returns the normalized origin (no trailing slash) or null if invalid.
*/
function validateOrigin(raw: string): string | null {
export function validateOrigin(raw: string): string | null {
try {
const url = new URL(raw);
if (url.protocol !== 'http:' && url.protocol !== 'https:') return null;