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.

This commit is contained in:
kuekhaoyang
2025-11-23 16:39:26 +08:00
parent f3b3da3285
commit e2b31aa37d
+3 -1
View File
@@ -28,7 +28,9 @@ export async function parseHLSManifest(src: string): Promise<Segment[]> {
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,