maintain api compatibility
This commit is contained in:
parent
be50ca2653
commit
8557cd223c
2 changed files with 20 additions and 4 deletions
|
@ -115,14 +115,27 @@ struct Converter<net::ProxyConfig> {
|
|||
v8::Local<v8::Value> val,
|
||||
net::ProxyConfig* out) {
|
||||
mate::Dictionary options;
|
||||
if (!ConvertFromV8(isolate, val, &options))
|
||||
return false;
|
||||
if (!ConvertFromV8(isolate, val, &options)) {
|
||||
// Fallback to previous api (https://git.io/vuhjj).
|
||||
std::string proxy;
|
||||
if (!ConvertFromV8(isolate, val, &proxy))
|
||||
return false;
|
||||
auto pac_url = GURL(proxy);
|
||||
if (pac_url.is_valid()) {
|
||||
out->set_pac_url(pac_url);
|
||||
} else {
|
||||
out->proxy_rules().ParseFromString(proxy);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
GURL pac_url;
|
||||
std::string rules;
|
||||
if (options.Get("pacScript", &pac_url))
|
||||
if (options.Get("pacScript", &pac_url)) {
|
||||
out->set_pac_url(pac_url);
|
||||
else if (options.Get("proxyRules", &rules))
|
||||
} else if (options.Get("proxyRules", &rules)) {
|
||||
out->proxy_rules().ParseFromString(rules);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue