mirror of
https://github.com/KuekHaoYang/KVideo.git
synced 2026-08-15 00:33:44 +08:00
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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user