UNPKG

945 BJavaScriptView Raw
1import QUnit from 'qunit';
2import window from 'global/window';
3import resolveUrl from '../src/resolve-url';
4
5// A modified subset of tests from https://github.com/tjenkinson/url-toolkit
6
7QUnit.module('URL resolver');
8
9QUnit.test('works with a selection of valid urls', function(assert) {
10 let currentLocation = window.location.protocol + '//' + window.location.host;
11
12 assert.equal(resolveUrl('http://a.com/b/cd/e.m3u8', 'https://example.com/z.ts'), 'https://example.com/z.ts');
13 assert.equal(resolveUrl('http://a.com/b/cd/e.m3u8', 'z.ts'), 'http://a.com/b/cd/z.ts');
14 assert.equal(resolveUrl('//a.com/b/cd/e.m3u8', 'z.ts'), '//a.com/b/cd/z.ts');
15 assert.equal(resolveUrl('/a/b/cd/e.m3u8', 'https://example.com:8080/z.ts'), 'https://example.com:8080/z.ts');
16 assert.equal(resolveUrl('/a/b/cd/e.m3u8', 'z.ts'), currentLocation + '/a/b/cd/z.ts');
17 assert.equal(resolveUrl('/a/b/cd/e.m3u8', '../../../z.ts'), currentLocation + '/z.ts');
18});