Answer the question
In order to leave comments, you need to log in
Why doesn't the shExpMatch function inside pacScript work?
I am writing an extension for Google Chrome that would change the proxy in the browser on the fly depending on the address.
Added the following config to background.js:
config = {
mode: "pac_script",
pacScript: {
data: `
function FindProxyForURL(url, host) {
if (shExpMatch(url, "*1")) {
return 'PROXY 193.56.186.165:65233';
}
}
`
}
};
chrome.proxy.settings.set(
{value: config, scope: 'regular'},
function() {}
);
Answer the question
In order to leave comments, you need to log in
I found what is the problem. It turned out that the full address of the open page is passed to the url variable inside the pac script only if the site is opened via the http protocol . In the event that the site is opened using the https protocol, the browser cuts paths leaving only the domain:
The URL being accessed. The path and query components of https:// URLs are stripped. In Chrome (versions 52 to 73), you can disable this by setting PacHttpsUrlStrippingEnabled to false in policy or by launching with the --unsafe-pac-url command-line flag (in Chrome 74, only the flag works, and from 75 onward, there is no way to disable path-stripping; as of Chrome 81, path-stripping does not apply to HTTP URLs, but there is interest in changing this behavior to match HTTPS); in Firefox, the preference is network.proxy.autoconfig_url.include_path.
You have a problem understanding reg. expressions and not with a function.
That is, in theory, if the site address contains a unit at the end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question