From 7a3190d478049751e47a16d7de80c0bfa466f4bf Mon Sep 17 00:00:00 2001 From: kumarrishav Date: Thu, 27 Apr 2017 06:09:38 +0530 Subject: [PATCH] Opening PDF via Wayback machine should not change the url Fix #6726 --- js/lib/urlutil.js | 2 +- test/unit/lib/urlutilTest.js | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/js/lib/urlutil.js b/js/lib/urlutil.js index 7a7d55c0c2..cb53da687a 100644 --- a/js/lib/urlutil.js +++ b/js/lib/urlutil.js @@ -307,7 +307,7 @@ const UrlUtil = { */ getLocationIfPDF: function (url) { if (url && url.startsWith(`chrome-extension://${pdfjsExtensionId}/`)) { - return url.replace(/^chrome-extension:\/\/.+\/(\w+:\/\/.+)/, '$1') + return url.replace(`chrome-extension://${pdfjsExtensionId}/`, '') } return url }, diff --git a/test/unit/lib/urlutilTest.js b/test/unit/lib/urlutilTest.js index be4a9e0c79..8e1693438d 100644 --- a/test/unit/lib/urlutilTest.js +++ b/test/unit/lib/urlutilTest.js @@ -244,6 +244,10 @@ describe('urlutil', function () { assert.equal(UrlUtil.getLocationIfPDF('chrome-extension://jdbefljfgobbmcidnmpjamcbhnbphjnb/https://www.blackhat.co…king-Kernel-Address-Space-Layout-Randomization-KASLR-With-Intel-TSX-wp.pdf'), 'https://www.blackhat.co…king-Kernel-Address-Space-Layout-Randomization-KASLR-With-Intel-TSX-wp.pdf') }) + it('does not remove wayback machine url location for PDF JS URL', function () { + assert.equal(UrlUtil.getLocationIfPDF('chrome-extension://jdbefljfgobbmcidnmpjamcbhnbphjnb/https://web.archive.org/web/20160106152308/http://stlab.adobe.com/wiki/images/d/d3/Test.pdf'), + 'https://web.archive.org/web/20160106152308/http://stlab.adobe.com/wiki/images/d/d3/Test.pdf') + }) it('does not modify location for non-pdf URL', function () { assert.equal(UrlUtil.getLocationIfPDF('https://www.blackhat.co…king-Kernel-Address-Space-Layout-Randomization-KASLR-With-Intel-TSX-wp.pdf'), 'https://www.blackhat.co…king-Kernel-Address-Space-Layout-Randomization-KASLR-With-Intel-TSX-wp.pdf')