Browse Source

fix: use is_valid for cookie url validation (#18770) (#18843)

Use is_valid instead of is_empty to validate url on cookies.set().
Shelley Vohr 5 years ago
parent
commit
eb15be06e3
2 changed files with 2 additions and 2 deletions
  1. 1 1
      atom/browser/api/atom_api_cookies.cc
  2. 1 1
      docs/api/cookies.md

+ 1 - 1
atom/browser/api/atom_api_cookies.cc

@@ -291,7 +291,7 @@ void SetCookieOnIO(scoped_refptr<net::URLRequestContextGetter> getter,
                  EXCLUDE_FAILURE_TO_STORE);
     return;
   }
-  if (url.is_empty()) {
+  if (!url.is_valid()) {
     std::move(completion_callback)
         .Run(net::CanonicalCookie::CookieInclusionStatus::
                  EXCLUDE_INVALID_DOMAIN);

+ 1 - 1
docs/api/cookies.md

@@ -104,7 +104,7 @@ with `callback(error, cookies)` on complete.
 #### `cookies.set(details)`
 
 * `details` Object
-  * `url` String - The url to associate the cookie with.
+  * `url` String - The url to associate the cookie with. The promise will be rejected if the url is invalid.
   * `name` String (optional) - The name of the cookie. Empty by default if omitted.
   * `value` String (optional) - The value of the cookie. Empty by default if omitted.
   * `domain` String (optional) - The domain of the cookie; this will be normalized with a preceding dot so that it's also valid for subdomains. Empty by default if omitted.