From 8557cd223cee2d4e61d33252ee0ec5cd900c1eeb Mon Sep 17 00:00:00 2001 From: Robo Date: Mon, 11 Jan 2016 12:24:01 +0530 Subject: [PATCH] maintain api compatibility --- atom/browser/api/atom_api_session.cc | 21 +++++++++++++++++---- docs/api/session.md | 3 +++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/atom/browser/api/atom_api_session.cc b/atom/browser/api/atom_api_session.cc index 0b2f4f9be..379d16ecf 100644 --- a/atom/browser/api/atom_api_session.cc +++ b/atom/browser/api/atom_api_session.cc @@ -115,14 +115,27 @@ struct Converter { v8::Local 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; } }; diff --git a/docs/api/session.md b/docs/api/session.md index 67dd537d4..41d27773f 100644 --- a/docs/api/session.md +++ b/docs/api/session.md @@ -186,6 +186,9 @@ Clears the data of web storages. * `proxyRules` String - Rules indicating which proxies to use. * `callback` Function - Called when operation is done. +When `pacScript` and `proxyRules` are provided together, the `proxyRules` +option is ignored and `pacScript` configuration is applied. + ``` proxyRules = scheme-proxies[";"] scheme-proxies = ["="]