1 | import QUnit from 'qunit';
|
2 | import window from 'global/window';
|
3 | import resolveUrl from '../src/resolve-url';
|
4 |
|
5 |
|
6 |
|
7 | QUnit.module('URL resolver');
|
8 |
|
9 | QUnit.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 | });
|