Move the getPdfFilenameFromUrl helper function from web/ui_utils.js and into src/display/display_utils.js

It seems reasonable to place this alongside the *similar* `getFilenameFromUrl` helper function. This way, with the changes in the next patch, we also avoid having to expose the `isDataScheme` function in the API itself and we instead expose `getPdfFilenameFromUrl` in the API (which feels overall more appropriate).
This commit is contained in:
Jonas Jenwald 2021-03-16 11:56:31 +01:00
parent a164941351
commit bd9dee1544
8 changed files with 225 additions and 226 deletions

View file

@ -22,7 +22,6 @@ import {
DEFAULT_SCALE_VALUE,
EventBus,
getActiveOrFocusedElement,
getPDFFileNameFromURL,
isValidRotation,
isValidScrollMode,
isValidSpreadMode,
@ -44,6 +43,7 @@ import {
createPromiseCapability,
getDocument,
getFilenameFromUrl,
getPdfFilenameFromUrl,
GlobalWorkerOptions,
InvalidPDFException,
isPdfFile,
@ -748,7 +748,7 @@ const PDFViewerApplication = {
setTitleUsingUrl(url = "") {
this.url = url;
this.baseUrl = url.split("#")[0];
let title = getPDFFileNameFromURL(url, "");
let title = getPdfFilenameFromUrl(url, "");
if (!title) {
try {
title = decodeURIComponent(getFilenameFromUrl(url)) || url;
@ -772,7 +772,7 @@ const PDFViewerApplication = {
get _docFilename() {
// Use `this.url` instead of `this.baseUrl` to perform filename detection
// based on the reference fragment as ultimate fallback if needed.
return this._contentDispositionFilename || getPDFFileNameFromURL(this.url);
return this._contentDispositionFilename || getPdfFilenameFromUrl(this.url);
},
/**