Parameters not named url and host
info
Engines pass the arguments by position, so function FindProxyForURL(u, h) works. Every document, example and reviewer assumes url and host; deviating names invite mix-ups between the two (PAC-C001).
Why it matters
The two parameters are easy to confuse even with the standard names. Non-standard names
remove the one cue that tells a reader which string is which, and they defeat
pattern-based review tools that look for host and url. There is no benefit in renaming
them.
How to fix
Declare function FindProxyForURL(url, host).
Examples
Bad
function FindProxyForURL(u, h) {
if (isPlainHostName(h)) {
return "DIRECT";
}
return "PROXY proxy.corp.example:8080";
}
Open bad example in checkerGood
function FindProxyForURL(url, host) {
if (isPlainHostName(host)) {
return "DIRECT";
}
return "PROXY proxy.corp.example:8080";
}
Open good example in checkerRelated rules
- FindProxyForURL does not take exactly two parameters PAC-E004
- Hostname pattern applied to url instead of host PAC-C001