Skip to content

Commit a110814

Browse files
Copilotmuke1908
andauthored
feat: address code review - use slice for protocol strip and document default port normalisation
Agent-Logs-Url: https://github.com/muke1908/noconsole/sessions/1ed57d2a-3da8-486f-a3ce-fda13ae769e7 Co-authored-by: muke1908 <20297989+muke1908@users.noreply.github.com>
1 parent 0e3ee9e commit a110814

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

packages/streamer/server/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ function getNamespaceFromOrigin(originHeader) {
4444
if (!originHeader) return null;
4545
try {
4646
const { protocol, hostname, port } = new URL(originHeader);
47-
const scheme = protocol.replace(':', ''); // strip trailing colon
47+
const scheme = protocol.slice(0, -1); // strip trailing colon, e.g. "http:" → "http"
48+
// The URL API normalises default ports (80/443) to an empty string, so two
49+
// origins that differ only by the explicit presence of the default port
50+
// (e.g. http://host and http://host:80) produce the same namespace.
4851
const namespace = port
4952
? `${scheme}-${hostname}-${port}`
5053
: `${scheme}-${hostname}`;

0 commit comments

Comments
 (0)