Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: subscriptionLink.postload.js

Issue 29373686: Issue 4775 - Fix subscription links for Firefox (Closed)
Patch Set: Created Jan. 28, 2017, 12:31 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: subscriptionLink.postload.js
diff --git a/subscriptionLink.postload.js b/subscriptionLink.postload.js
index 0aaf68c78dd12e4f82afa3f37b3138529207893f..0facce1a1bd05a70249f353a0ad3de1812a69d3f 100644
--- a/subscriptionLink.postload.js
+++ b/subscriptionLink.postload.js
@@ -39,12 +39,23 @@ if (document instanceof HTMLDocument)
return;
}
+ let queryString = null;
kzar 2017/01/28 12:35:01 (The workaround that will apparently never die. Pr
if (link.protocol == "http:" || link.protocol == "https:")
{
- if (link.host != "subscribe.adblockplus.org" || link.pathname != "/")
- return;
+ if (link.host == "subscribe.adblockplus.org" && link.pathname == "/")
+ queryString = link.search.substr(1);
+ }
+ else
+ {
+ // Firefox 51 doesn't seem to populate the "search" property for
+ // links with non-standard URL schemes so we need to extract the query
+ // string manually.
+ let match = /^abp:\/*subscribe\/*\?(.*)/i.exec(link.href);
+ if (match)
+ queryString = match[1];
}
- else if (!/^abp:\/*subscribe\/*\?/i.test(link.href))
+
+ if (!queryString)
return;
// This is our link - make sure the browser doesn't handle it
@@ -54,7 +65,7 @@ if (document instanceof HTMLDocument)
// Decode URL parameters
let title = null;
let url = null;
- for (let param of link.search.substr(1).split("&"))
+ for (let param of queryString.split("&"))
{
let parts = param.split("=", 2);
if (parts.length != 2 || !/\S/.test(parts[1]))
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld