Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions tests/radio-source-plan.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -216,3 +216,19 @@ test("does not re-proxy an already proxied URL with canonical-equivalent host ca
[otherStream, "https://cors.example/https://radio.example/live.mp3"],
);
});

test("rejects proxy URLs with empty query or fragment delimiters", () => {
const source = [{ src: "https://radio.example/live.mp3" }];
for (const proxy of [
"https://proxy.example/?",
"https://proxy.example/#",
"https://proxy.example/path?",
"https://proxy.example/path#",
]) {
assert.deepEqual(
buildPlaybackSources(source, proxy).map(item => item.src),
[source[0].src],
proxy,
);
}
});
2 changes: 1 addition & 1 deletion utils/radio-source-plan.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const normalizeProxyBase = (value) => {
// an unusable playback candidate (or exposing credentials in its URL).
try {
const url = new URL(base);
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.search || url.hash) return "";
if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || base.includes("?") || base.includes("#")) return "";
return base.endsWith("/") ? base : `${base}/`;
} catch { return ""; }
};
Expand Down
Loading