Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #8518 from kumarrishav/pdfURLfix
Browse files Browse the repository at this point in the history
Opening PDF via Wayback machine should not change the url Fix #6726
  • Loading branch information
diracdeltas authored Apr 29, 2017
2 parents db27624 + 7a3190d commit 4d2b95e
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion js/lib/urlutil.js
Original file line number Diff line number Diff line change
@@ -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
},
4 changes: 4 additions & 0 deletions test/unit/lib/urlutilTest.js
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 4d2b95e

Please sign in to comment.