Skip to content

Commit

Permalink
Account for empty host in CommonAccessTokenController.js (#4445)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsilhavy committed Apr 4, 2024
1 parent ff66d15 commit 1816773
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/core/Utils.js
Expand Up @@ -181,9 +181,13 @@ class Utils {
}

static getHostFromUrl(urlString) {
const url = new URL(urlString);
try {
const url = new URL(urlString);

return url.host
return url.host
} catch (e) {
return null
}
}

static parseUserAgent(ua = null) {
Expand Down
4 changes: 3 additions & 1 deletion src/streaming/controllers/CommonAccessTokenController.js
Expand Up @@ -58,7 +58,9 @@ function CommonAccessTokenController() {
}

const host = Utils.getHostFromUrl(url);
return hostTokenMap[host] ? hostTokenMap[host] : null;
if (host) {
return hostTokenMap[host] ? hostTokenMap[host] : null;
}
}

function setup() {
Expand Down

0 comments on commit 1816773

Please sign in to comment.