Ignore port numbers when extracting domain names
Hi,
In RequestAnalyzer, I noticed new URL(url).host was used. Updated it to new URL(url).hostname in this Pull Request.
Reason: new URL(url).host can return "hostname:port" if port is present in URL, then it would not match with the mappings object map. new URL(url).hostname will always return just hostname without the port.
Example: https://b.somecdn.com:443/path/ -> host will return b.somecdn.com:443 but hostname returns just b.somecdn.com
Merge request reports
Activity
added 1 commit
- b74c9ed8 - Updated helpers.js for URL.hostname in place of URL.host
Hi again @gkrishnaks, thanks for your contributions; highly appreciated!
Coincidentally, during the latest rewrite, I ended up switching everything related to domain whitelisting and domain exceptions over to
hostname
. This was, first and foremost, done to be able to integratedeclarativeNetRequest
where needed. 1That said, I am not sure if it would be a good idea to implement that first suggestion. Doing so would make the extension inject local resources for hosts that do not serve them (e.g.
ajax.googleapis.com:8080
). What are your thoughts on this?Edited by Thomas RientjesExample:
https://b.somecdn.com:443/path/
host will returnb.somecdn.com:443
[...].Even when parsing
https://b.somecdn.com:443/path/
, thehost
property should beb.somecdn.com
, as the port number matches the protocol's default port number. The same would also be true forhttp://b.somecdn.com:80/path/
.Edited by Thomas Rientjes