Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/rspack/hot/lazy-compilation-web.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@ if (typeof EventSource !== "function") {
}

var urlBase = decodeURIComponent(__resourceQuery.slice(1));
if (
!urlBase.startsWith("http") &&
!urlBase.startsWith("//") &&
typeof __rspack_dev_server_uri !== "undefined"
) {
urlBase = __rspack_dev_server_uri + urlBase;
Copy link

Copilot AI Nov 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential URL concatenation issue: When concatenating __rspack_dev_server_uri with urlBase, there's no handling for trailing/leading slashes. This could result in malformed URLs like http://example.com//path (double slash) or http://example.compath (missing slash).

Consider normalizing the URL concatenation:

var separator = __rspack_dev_server_uri.endsWith("/") || urlBase.startsWith("/") ? "" : "/";
urlBase = __rspack_dev_server_uri + separator + urlBase;

Or ensure proper slash handling:

urlBase = __rspack_dev_server_uri.replace(/\/$/, "") + "/" + urlBase.replace(/^\//, "");
Suggested change
urlBase = __rspack_dev_server_uri + urlBase;
urlBase = __rspack_dev_server_uri.replace(/\/$/, "") + "/" + urlBase.replace(/^\//, "");

Copilot uses AI. Check for mistakes.
}

/** @type {EventSource | undefined} */
var activeEventSource;
var compiling = new Set();
Expand Down
Loading