mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 23:28:06 +02:00
Remove combineUrl
and replace it with new URL
.
This commit is contained in:
parent
e9dbb233aa
commit
a25c29d98d
5 changed files with 7 additions and 78 deletions
|
@ -332,9 +332,7 @@ var Driver = (function DriverClosure() {
|
|||
|
||||
this._log('Loading file "' + task.file + '"\n');
|
||||
|
||||
var absoluteUrl = pdfjsSharedUtil.combineUrl(window.location.href,
|
||||
task.file);
|
||||
|
||||
var absoluteUrl = new URL(task.file, window.location).href;
|
||||
PDFJS.disableRange = task.disableRange;
|
||||
PDFJS.disableAutoFetch = !task.enableAutoFetch;
|
||||
try {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/* globals expect, it, describe, Dict, Name, Annotation, AnnotationBorderStyle,
|
||||
AnnotationBorderStyleType, AnnotationFlag, PDFJS, combineUrl,
|
||||
AnnotationBorderStyleType, AnnotationFlag, PDFJS,
|
||||
beforeEach, afterEach, stringToBytes */
|
||||
|
||||
'use strict';
|
||||
|
@ -179,8 +179,8 @@ describe('Annotation layer', function() {
|
|||
var annotations;
|
||||
|
||||
beforeEach(function(done) {
|
||||
var pdfUrl = combineUrl(window.location.href,
|
||||
'../pdfs/annotation-fileattachment.pdf');
|
||||
var pdfUrl = new URL('../pdfs/annotation-fileattachment.pdf',
|
||||
window.location).href;
|
||||
loadingTask = PDFJS.getDocument(pdfUrl);
|
||||
loadingTask.promise.then(function(pdfDocument) {
|
||||
return pdfDocument.getPage(1).then(function(pdfPage) {
|
||||
|
|
|
@ -1,67 +1,9 @@
|
|||
/* globals expect, it, describe, combineUrl, Dict, isDict, Name, PDFJS,
|
||||
/* globals expect, it, describe, Dict, isDict, Name, PDFJS,
|
||||
stringToPDFString, removeNullCharacters */
|
||||
|
||||
'use strict';
|
||||
|
||||
describe('util', function() {
|
||||
describe('combineUrl', function() {
|
||||
it('absolute url with protocol stays as is', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = 'http://server2/test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server2/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('absolute url without protocol uses prefix from base', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = '/test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('combines relative url with base', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = 'test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('combines relative url (w/hash) with base', function() {
|
||||
var baseUrl = 'http://server/index.html#!/test';
|
||||
var url = 'test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('combines relative url (w/query) with base', function() {
|
||||
var baseUrl = 'http://server/index.html?search=/test';
|
||||
var url = 'test2.html';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/test2.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('returns base url when url is empty', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url = '';
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/index.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
|
||||
it('returns base url when url is undefined', function() {
|
||||
var baseUrl = 'http://server/index.html';
|
||||
var url;
|
||||
var result = combineUrl(baseUrl, url);
|
||||
var expected = 'http://server/index.html';
|
||||
expect(result).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isDict', function() {
|
||||
it('handles empty dictionaries with type check', function() {
|
||||
var dict = new Dict();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue