From 5fdc908f020c63e129a9a66b76a7a31c69f8321d Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Sat, 4 Feb 2017 00:56:15 +0100 Subject: [PATCH] Recognize file name in reference fragment in getPDFFileNameFromURL The regular expression incorrectly marked a group as capturing. For `http://example.com/#file.pdf`, the expected result is "file.pdf", but instead "document.pdf" was returned. --- web/ui_utils.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web/ui_utils.js b/web/ui_utils.js index fd925d1ba..6e9cc9d30 100644 --- a/web/ui_utils.js +++ b/web/ui_utils.js @@ -371,8 +371,8 @@ function noContextMenuHandler(e) { * @return {String} Guessed PDF file name. */ function getPDFFileNameFromURL(url) { - var reURI = /^(?:([^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/; - // SCHEME HOST 1.PATH 2.QUERY 3.REF + var reURI = /^(?:(?:[^:]+:)?\/\/[^\/]+)?([^?#]*)(\?[^#]*)?(#.*)?$/; + // SCHEME HOST 1.PATH 2.QUERY 3.REF // Pattern to get last matching NAME.pdf var reFilename = /[^\/?#=]+\.pdf\b(?!.*\.pdf\b)/i; var splitURI = reURI.exec(url);