From 15bd03530461a1133ce52703ef47034d6a418319 Mon Sep 17 00:00:00 2001 From: telami <907848106@qq.com> Date: Mon, 27 Apr 2020 21:36:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=EF=BC=9A=E9=9C=80=E6=B1=82ht?= =?UTF-8?q?tps://gitee.com/kekingcn/file-online-preview/issues/I14D4X,?= =?UTF-8?q?=E5=BD=93=E4=BD=BF=E7=94=A8nginx=E5=81=9A=E4=BB=A3=E7=90=86?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E9=85=8D=E7=BD=AE=E4=BA=86content-path?= =?UTF-8?q?=E5=92=8CbaseUrl=E6=97=B6=EF=BC=8C=E8=AE=BF=E9=97=AEview.html?= =?UTF-8?q?=E5=92=8CgetCorsFile=E4=BC=9A=E5=87=BA=E7=8E=B0404?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/static/pdfjs/web/viewer.js | 8 +++++--- jodconverter-web/src/main/resources/web/pdf.ftl | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/jodconverter-web/src/main/resources/static/pdfjs/web/viewer.js b/jodconverter-web/src/main/resources/static/pdfjs/web/viewer.js index 9c20bb2f..6bd7cd94 100644 --- a/jodconverter-web/src/main/resources/static/pdfjs/web/viewer.js +++ b/jodconverter-web/src/main/resources/static/pdfjs/web/viewer.js @@ -1886,7 +1886,7 @@ var PDFViewerApplication = { var validateFileURL = void 0; { var HOSTED_VIEWER_ORIGINS = ['null', 'http://mozilla.github.io', 'https://mozilla.github.io']; - validateFileURL = function validateFileURL(file) { + validateFileURL = function validateFileURL(file,base) { if (file === undefined) { return file; } @@ -1897,7 +1897,7 @@ var validateFileURL = void 0; } var fileOrigin = new URL(file, window.location.href).origin; if (fileOrigin !== viewerOrigin) { - return '/getCorsFile?urlPath=' + encodeURIComponent(file); + return base.endsWith('/') ? base : '/' + 'getCorsFile?urlPath=' + encodeURIComponent(file); } } catch (ex) { var message = ex && ex.message; @@ -1931,10 +1931,12 @@ function loadAndEnablePDFBug(enabledTabs) { function webViewerInitialized() { var appConfig = PDFViewerApplication.appConfig; var file = void 0; + var base = void 0; var queryString = document.location.search.substring(1); var params = (0, _ui_utils.parseQueryString)(queryString); file = 'file' in params ? params.file : appConfig.defaultUrl; - file = validateFileURL(file); + base = 'base' in params ? params.base : appConfig.defaultUrl; + file = validateFileURL(file,base); var waitForBeforeOpening = []; var fileInput = document.createElement('input'); fileInput.id = appConfig.openFileInputName; diff --git a/jodconverter-web/src/main/resources/web/pdf.ftl b/jodconverter-web/src/main/resources/web/pdf.ftl index 12dd8ca8..d36d91ec 100644 --- a/jodconverter-web/src/main/resources/web/pdf.ftl +++ b/jodconverter-web/src/main/resources/web/pdf.ftl @@ -28,7 +28,7 @@