]> git.parisson.com Git - pdf.js.git/commitdiff
Chrome extension: uses encodeURIComponent; fixes download button
authornotmasteryet <async.processingjs@yahoo.com>
Sun, 4 Mar 2012 01:27:35 +0000 (19:27 -0600)
committernotmasteryet <async.processingjs@yahoo.com>
Sun, 4 Mar 2012 01:27:35 +0000 (19:27 -0600)
extensions/chrome/pdfHandler.html

index 1d213bbba1a9b7ef1a5e386c04140f8ba8d453da..fc67c581da86a74ec6e468e2423e87cfe74c885d 100644 (file)
@@ -1,18 +1,28 @@
 <!doctype html>
 <script>
+
+function isPdfDownloadable(details) {
+  return details.url.indexOf('pdfjs.action=download') >= 0;
+}
+
 chrome.webRequest.onBeforeRequest.addListener(
   function(details) {
+    if (isPdfDownloadable(details))
+      return;
+
     var viewerPage = 'content/web/viewer.html';
-    var url = chrome.extension.getURL(viewerPage) + '?file=' + details.url;
+    var url = chrome.extension.getURL(viewerPage) +
+      '?file=' + encodeURIComponent(details.url);
     return { redirectUrl: url };
   },
   {
     urls: [
       "http://*/*.pdf",
-      "file://*/*.pdf",
+      "file://*/*.pdf"
     ],
     types: [ "main_frame" ]
   },
   ["blocking"]);
+
 </script>