Skip to content

Commit

Permalink
feat(FEC-8281): support jsonP redirect for OTT (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
OrenMe authored Jun 4, 2018
1 parent f96982d commit 34b4cf4
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/common/utils/external-stream-redirect-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,22 @@ function getDirectManifestUri(data: Object, uri: string): string {
// if the json contains one url, it means it is a redirect url. if it contains few urls, it means its the flavours
// so we should use the original url.
const uriHost = getHostName(uri);
const hasOneFlavor = data && data.flavors && (data.flavors.length === 1);
const flavorUriHost = hasOneFlavor && getHostName(data.flavors[0].url);
if (hasOneFlavor && (uriHost !== flavorUriHost)) {
return data.flavors[0].url;
let hasOneFlavor = false;
let redirectedUriHost = "";
let redirectedUri = "";
if (data) {
if (data.flavors && Array.isArray(data.flavors)) {
hasOneFlavor = data.flavors.length === 1;
redirectedUriHost = hasOneFlavor && getHostName(data.flavors[0].url);
redirectedUri = data.flavors[0].url;
} else if (data.result) {
hasOneFlavor = true;
redirectedUriHost = getHostName(data.result.url);
redirectedUri = data.result.url;
}
}
if (hasOneFlavor && (uriHost !== redirectedUriHost)) {
return redirectedUri;
}
return uri;
}
Expand Down

0 comments on commit 34b4cf4

Please sign in to comment.