|
|
@ -341,25 +341,14 @@ function isDataSchema(url) {
|
|
|
|
return url.substr(i, 5).toLowerCase() === 'data:';
|
|
|
|
return url.substr(i, 5).toLowerCase() === 'data:';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function getPDFFileNameFromURL(url) {
|
|
|
|
function getPDFFileNameFromURL(url) {
|
|
|
|
var defaultFilename = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'document.pdf';
|
|
|
|
var query;
|
|
|
|
|
|
|
|
var title;
|
|
|
|
if (isDataSchema(url)) {
|
|
|
|
if (/\?/.test(url)) {
|
|
|
|
console.warn('getPDFFileNameFromURL: ' + 'ignoring "data:" URL for performance reasons.');
|
|
|
|
url.replace(/\?(.*)$/, function (all, t) {
|
|
|
|
return defaultFilename;
|
|
|
|
title = t;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/;
|
|
|
|
|
|
|
|
var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i;
|
|
|
|
|
|
|
|
var splitURI = reURI.exec(url);
|
|
|
|
|
|
|
|
var suggestedFilename = reFilename.exec(splitURI[1]) || reFilename.exec(splitURI[2]) || reFilename.exec(splitURI[3]);
|
|
|
|
|
|
|
|
if (suggestedFilename) {
|
|
|
|
|
|
|
|
suggestedFilename = suggestedFilename[0];
|
|
|
|
|
|
|
|
if (suggestedFilename.indexOf('%') !== -1) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
suggestedFilename = reFilename.exec(decodeURIComponent(suggestedFilename))[0];
|
|
|
|
|
|
|
|
} catch (e) {}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return suggestedFilename || defaultFilename;
|
|
|
|
return title || 'document.pdf';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function normalizeWheelEventDelta(evt) {
|
|
|
|
function normalizeWheelEventDelta(evt) {
|
|
|
|
var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
|
|
|
|
var delta = Math.sqrt(evt.deltaX * evt.deltaX + evt.deltaY * evt.deltaY);
|
|
|
@ -1192,11 +1181,13 @@ var PDFViewerApplication = {
|
|
|
|
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
|
|
|
|
setTitleUsingUrl: function pdfViewSetTitleUsingUrl(url) {
|
|
|
|
this.url = url;
|
|
|
|
this.url = url;
|
|
|
|
this.baseUrl = url.split('#')[0];
|
|
|
|
this.baseUrl = url.split('#')[0];
|
|
|
|
var title = (0, _ui_utils.getPDFFileNameFromURL)(url, '');
|
|
|
|
|
|
|
|
|
|
|
|
var title = _ui_utils.getPDFFileNameFromURL(url);
|
|
|
|
if (!title) {
|
|
|
|
if (!title) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
|
|
|
|
title = decodeURIComponent((0, _pdfjsLib.getFilenameFromUrl)(url)) || url;
|
|
|
|
} catch (e) {
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.error(e)
|
|
|
|
title = url;
|
|
|
|
title = url;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|