From 2ff5218b6c7e24103ee37e0b8c0f7b04a1988199 Mon Sep 17 00:00:00 2001 From: Will Harney Date: Wed, 8 Jan 2025 10:03:52 -0500 Subject: [PATCH] revert: use runtime-agnostic `domainToASCII` --- lib/cookie/canonicalDomain.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/cookie/canonicalDomain.ts b/lib/cookie/canonicalDomain.ts index 67179d21..0dbdb7b0 100644 --- a/lib/cookie/canonicalDomain.ts +++ b/lib/cookie/canonicalDomain.ts @@ -1,6 +1,14 @@ import { IP_V6_REGEX_OBJECT } from './constants' import type { Nullable } from '../utils' -import { domainToASCII } from 'node:url' + +/** + * Normalizes a domain to lowercase and punycode-encoded. + * Runtime-agnostic equivalent to node's `domainToASCII`. + * @see https://nodejs.org/docs/latest-v22.x/api/url.html#urldomaintoasciidomain + */ +function domainToASCII(domain: string): string { + return new URL(`http://${domain}`).hostname +} /** * Transforms a domain name into a canonical domain name. The canonical domain name is a domain name