From e1ea1c68d1170ccac2a180d57a3403ee6573d0e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jamal=20Almonawer=20=D8=AC=D9=85=D8=A7=D9=84=20=D8=A7?= =?UTF-8?q?=D9=84=D9=85=D9=86=D8=A7=D9=88=D8=B1?= <49294268+jeme95@users.noreply.github.com> Date: Mon, 3 Feb 2025 18:02:00 +0100 Subject: [PATCH] Fix: Ensure normalizeURL retains port number (#3959) * fix: Preserve port in normalizeURL function The normalizeURL function was previously ignoring the port in the URL. This fix explicitly includes the port if present (e.g., `:3000`). * fix lint problem fix lint problem --- packages/components/src/utils.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/components/src/utils.ts b/packages/components/src/utils.ts index f8bc9801..7fc8426b 100644 --- a/packages/components/src/utils.ts +++ b/packages/components/src/utils.ts @@ -378,7 +378,8 @@ function getURLsFromHTML(htmlBody: string, baseURL: string): string[] { */ function normalizeURL(urlString: string): string { const urlObj = new URL(urlString) - const hostPath = urlObj.hostname + urlObj.pathname + urlObj.search + const port = urlObj.port ? `:${urlObj.port}` : '' + const hostPath = urlObj.hostname + port + urlObj.pathname + urlObj.search if (hostPath.length > 0 && hostPath.slice(-1) == '/') { // handling trailing slash return hostPath.slice(0, -1)