Suggestion to fix NS_ERROR_ILLEGAL_VALUE error on local pages

Minor problem when parsing locally served web pages, (quick and dirty development) will throw an error with file:// protocol in function 'belongsToHost'

Error: NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMLocation.replace]
Source File: chrome://ghostery/content/ghostery-common.js
Line: 1158

Not sure why but the host value is not a string under such circumstances, but using the String function fixes the error, my tweak:

// returns true if url belongs to host's top or sub-domain
belongsToHost: function(url, host) {
host = String(host).replace(/^www\./, '');
url = ghostery.prefs.parseUri.parse(url).host;
return (url.indexOf(host) !== -1);
},
1 person likes
this idea
+1
Reply