Skip to content

Commit

Permalink
feat: node support
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonocasey committed Aug 30, 2019
2 parents 49e36b2 + 315ab8d commit 12898d6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
"lint": "vjsstandard",
"server": "karma start scripts/karma.conf.js --singleRun=false --auto-watch",
"start": "npm-run-all -p server watch",
"test": "npm-run-all lint build-test && karma start scripts/karma.conf.js",
"test": "npm-run-all lint build-test && npm-run-all test:*",
"test:browser": "karma start scripts/karma.conf.js",
"test:node": "qunit test/dist/bundle.js",
"posttest": "shx cat test/dist/coverage/text.txt",
"update-changelog": "conventional-changelog -p videojs -i CHANGELOG.md -s",
"preversion": "npm test",
Expand Down
4 changes: 3 additions & 1 deletion src/decode-b64-to-uint8-array.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import window from 'global/window';

const atob = (s) => window.atob ? window.atob(s) : Buffer.from(s, 'base64').toString('binary');

export default function decodeB64ToUint8Array(b64Text) {
const decodedString = window.atob(b64Text);
const decodedString = atob(b64Text);
const array = new Uint8Array(decodedString.length);

for (let i = 0; i < decodedString.length; i++) {
Expand Down
2 changes: 1 addition & 1 deletion src/resolve-url.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const resolveUrl = (baseUrl, relativeUrl) => {

// if the base URL is relative then combine with the current location
if (!(/\/\//i).test(baseUrl)) {
baseUrl = URLToolkit.buildAbsoluteURL(window.location.href, baseUrl);
baseUrl = URLToolkit.buildAbsoluteURL(window.location && window.location.href || '', baseUrl);
}

return URLToolkit.buildAbsoluteURL(baseUrl, relativeUrl);
Expand Down
6 changes: 5 additions & 1 deletion test/resolve-url.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import resolveUrl from '../src/resolve-url';
QUnit.module('URL resolver');

QUnit.test('works with a selection of valid urls', function(assert) {
const currentLocation = window.location.protocol + '//' + window.location.host;
let currentLocation = '';

if (window.location && window.location.protocol) {
currentLocation = window.location.protocol + '//' + window.location.host;
}

assert.equal(
resolveUrl('http://a.com/b/cd/e.m3u8', 'https://example.com/z.ts'),
Expand Down

0 comments on commit 12898d6

Please sign in to comment.