From e2b31aa37dad61d701402a3a158021be00d8ecda Mon Sep 17 00:00:00 2001 From: kuekhaoyang Date: Sun, 23 Nov 2025 16:39:26 +0800 Subject: [PATCH] fix: Use URL API to robustly resolve HLS segment URLs against the manifest base.fix: Use URL API to robustly resolve HLS segment URLs against the manifest base. --- lib/utils/hlsManifestParser.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utils/hlsManifestParser.ts b/lib/utils/hlsManifestParser.ts index 8a41efb..c0dfe39 100644 --- a/lib/utils/hlsManifestParser.ts +++ b/lib/utils/hlsManifestParser.ts @@ -28,7 +28,9 @@ export async function parseHLSManifest(src: string): Promise { const durationStr = trimmed.substring(8).split(',')[0]; currentSegmentDuration = parseFloat(durationStr); } else if (trimmed && !trimmed.startsWith('#')) { - const segmentUrl = trimmed.startsWith('http') ? trimmed : baseUrl + trimmed; + // Use URL API to resolve relative paths correctly against the manifest URL + // This handles cases where baseUrl might end with / and segment starts with / + const segmentUrl = new URL(trimmed, src).toString(); segments.push({ url: segmentUrl, duration: currentSegmentDuration,