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