Skip to content

Commit

Permalink
fix: parse base url without manifest url
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalygashkov committed Apr 23, 2024
1 parent 6964304 commit 0f1b8c1
Show file tree
Hide file tree
Showing 5 changed files with 551 additions and 18 deletions.
16 changes: 6 additions & 10 deletions lib/dash.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,12 @@ const combineGetters = (representation, adaptationSet) => {
};

const parseBaseUrl = (manifestUrl, mpd, period, representation) => {
let manifestBaseUrl = mpd.getBaseUrl();
if (!manifestBaseUrl) manifestBaseUrl = manifestUrl;
else if (!manifestBaseUrl.startsWith('https://'))
manifestBaseUrl = new URL(manifestBaseUrl, manifestUrl).toString();
const periodBaseUrl = new URL(period.getBaseUrl() || '', manifestBaseUrl).toString();
const representationBaseUrl = new URL(
representation.getBaseUrl() || '',
periodBaseUrl
).toString();
return representationBaseUrl;
let base = mpd.getBaseUrl();
if (!base) base = manifestUrl;
else if (!base.startsWith('https://')) base = new URL(base, manifestUrl).toString();
if (!!period.getBaseUrl() || !!base) base = new URL(period.getBaseUrl() || '', base).toString();
const baseUrl = new URL(representation.getBaseUrl() || '', base).toString();
return baseUrl;
};

const parseContentTypes = (representation) => {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dasha",
"version": "3.0.2",
"version": "3.0.3",
"author": "Vitaly Gashkov <[email protected]>",
"description": "Parser for MPEG-DASH & HLS manifests",
"license": "AGPL-3.0",
Expand Down
Loading

0 comments on commit 0f1b8c1

Please sign in to comment.