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
This commit is contained in:
Jamal Almonawer جمال المناور
2025-02-03 18:02:00 +01:00
committed by GitHub
parent 8d327e465c
commit e1ea1c68d1
+2 -1
View File
@@ -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)