mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-26 01:58:06 +02:00
Avoid using the Fetch API, in GENERIC
builds, for unsupported protocols (issue 10587)
This commit is contained in:
parent
cbc07f985b
commit
f664e074c9
3 changed files with 36 additions and 8 deletions
|
@ -14,7 +14,7 @@
|
|||
*/
|
||||
|
||||
import {
|
||||
DOMSVGFactory, getFilenameFromUrl
|
||||
DOMSVGFactory, getFilenameFromUrl, isValidFetchUrl
|
||||
} from '../../src/display/display_utils';
|
||||
import isNodeJS from '../../src/shared/is_node';
|
||||
|
||||
|
@ -94,4 +94,28 @@ describe('display_utils', function() {
|
|||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isValidFetchUrl', function() {
|
||||
it('handles invalid Fetch URLs', function() {
|
||||
expect(isValidFetchUrl(null)).toEqual(false);
|
||||
expect(isValidFetchUrl(100)).toEqual(false);
|
||||
expect(isValidFetchUrl('foo')).toEqual(false);
|
||||
expect(isValidFetchUrl('/foo', 100)).toEqual(false);
|
||||
});
|
||||
|
||||
it('handles relative Fetch URLs', function() {
|
||||
expect(isValidFetchUrl('/foo', 'file://www.example.com')).toEqual(false);
|
||||
expect(isValidFetchUrl('/foo', 'http://www.example.com')).toEqual(true);
|
||||
});
|
||||
|
||||
it('handles unsupported Fetch protocols', function() {
|
||||
expect(isValidFetchUrl('file://www.example.com')).toEqual(false);
|
||||
expect(isValidFetchUrl('ftp://www.example.com')).toEqual(false);
|
||||
});
|
||||
|
||||
it('handles supported Fetch protocols', function() {
|
||||
expect(isValidFetchUrl('http://www.example.com')).toEqual(true);
|
||||
expect(isValidFetchUrl('https://www.example.com')).toEqual(true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue