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

Unified Diff: include.postload.js

Issue 5132310882025472: Issue 704 - Generate protocol-agnostic request blocking filters with "Block element" (Closed)
Patch Set: Addressed comments Created June 28, 2014, 9:42 a.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: include.postload.js
===================================================================
--- a/include.postload.js
+++ b/include.postload.js
@@ -279,11 +279,6 @@
else if (elt.src)
url = elt.src;
- // Only normalize when the element contains a URL (issue 328.)
- // The URL is not always normalized, so do it here
- if (url)
- url = normalizeURL(relativeToAbsoluteUrl(url));
-
// Construct filters. The popup will retrieve these.
// Only one ID
var elementId = elt.id ? elt.id.split(' ').join('') : null;
@@ -315,10 +310,7 @@
}
if (url)
- {
- clickHideFilters.push(relativeToAbsoluteUrl(url));
- selectorList.push(elt.localName + '[src="' + url + '"]');
- }
+ clickHideFilters.push(normalizeURL(relativeToAbsoluteUrl(url)));
// restore the original style, before generating the fallback filter that
// will include the style, and to prevent highlightElements from saving those
@@ -397,15 +389,13 @@
// Does some degree of URL normalization
function normalizeURL(url)
Wladimir Palant 2014/09/30 21:27:42 The function name and comment no longer make sense
{
- var components = url.match(/(.+:\/\/.+?)\/(.*)/);
+ var components = url.match(/(.+:\/\/)(.+?)\/(.*)/);
Wladimir Palant 2014/09/30 21:27:42 This regexp won't work correctly for something lik
if(!components)
return url;
Wladimir Palant 2014/09/30 21:27:42 I guess this would make more sense: return "|"
- var newPath = removeDotSegments(components[2]);
- if(newPath.length == 0)
- return components[1];
- if(newPath[0] != '/')
- newPath = '/' + newPath;
- return components[1] + newPath;
+ var newPath = removeDotSegments(components[3]);
Wladimir Palant 2014/09/30 21:27:42 Do we still need the "dot removal"? This should be
+ if(newPath[0] != "/")
+ newPath = "/" + newPath;
+ return "||" + components[2] + newPath;
}
// Content scripts are apparently invoked on non-HTML documents, so we have to
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld