Skip to content

Commit 315ab8d

Browse files
committed
feat: node support and more stream tests
1 parent 49e36b2 commit 315ab8d

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
"lint": "vjsstandard",
1919
"server": "karma start scripts/karma.conf.js --singleRun=false --auto-watch",
2020
"start": "npm-run-all -p server watch",
21-
"test": "npm-run-all lint build-test && karma start scripts/karma.conf.js",
21+
"test": "npm-run-all lint build-test && npm-run-all test:*",
22+
"test:browser": "karma start scripts/karma.conf.js",
23+
"test:node": "qunit test/dist/bundle.js",
2224
"posttest": "shx cat test/dist/coverage/text.txt",
2325
"update-changelog": "conventional-changelog -p videojs -i CHANGELOG.md -s",
2426
"preversion": "npm test",

src/decode-b64-to-uint8-array.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import window from 'global/window';
22

3+
const atob = (s) => window.atob ? window.atob(s) : Buffer.from(s, 'base64').toString('binary');
4+
35
export default function decodeB64ToUint8Array(b64Text) {
4-
const decodedString = window.atob(b64Text);
6+
const decodedString = atob(b64Text);
57
const array = new Uint8Array(decodedString.length);
68

79
for (let i = 0; i < decodedString.length; i++) {

src/resolve-url.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const resolveUrl = (baseUrl, relativeUrl) => {
99

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

1515
return URLToolkit.buildAbsoluteURL(baseUrl, relativeUrl);

test/resolve-url.test.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@ import resolveUrl from '../src/resolve-url';
77
QUnit.module('URL resolver');
88

99
QUnit.test('works with a selection of valid urls', function(assert) {
10-
const currentLocation = window.location.protocol + '//' + window.location.host;
10+
let currentLocation = '';
11+
12+
if (window.location && window.location.protocol) {
13+
currentLocation = window.location.protocol + '//' + window.location.host;
14+
}
1115

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

0 commit comments

Comments
 (0)