Skip to content

Commit e1ea1c6

Browse files
authored
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
1 parent 8d327e4 commit e1ea1c6

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/components/src/utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,8 @@ function getURLsFromHTML(htmlBody: string, baseURL: string): string[] {
378378
*/
379379
function normalizeURL(urlString: string): string {
380380
const urlObj = new URL(urlString)
381-
const hostPath = urlObj.hostname + urlObj.pathname + urlObj.search
381+
const port = urlObj.port ? `:${urlObj.port}` : ''
382+
const hostPath = urlObj.hostname + port + urlObj.pathname + urlObj.search
382383
if (hostPath.length > 0 && hostPath.slice(-1) == '/') {
383384
// handling trailing slash
384385
return hostPath.slice(0, -1)

0 commit comments

Comments
 (0)