Path: blob/master/node_modules/axios/lib/helpers/cookies.js
1126 views
'use strict';12var utils = require('./../utils');34module.exports = (5utils.isStandardBrowserEnv() ?67// Standard browser envs support document.cookie8(function standardBrowserEnv() {9return {10write: function write(name, value, expires, path, domain, secure) {11var cookie = [];12cookie.push(name + '=' + encodeURIComponent(value));1314if (utils.isNumber(expires)) {15cookie.push('expires=' + new Date(expires).toGMTString());16}1718if (utils.isString(path)) {19cookie.push('path=' + path);20}2122if (utils.isString(domain)) {23cookie.push('domain=' + domain);24}2526if (secure === true) {27cookie.push('secure');28}2930document.cookie = cookie.join('; ');31},3233read: function read(name) {34var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));35return (match ? decodeURIComponent(match[3]) : null);36},3738remove: function remove(name) {39this.write(name, '', Date.now() - 86400000);40}41};42})() :4344// Non standard browser env (web workers, react-native) lack needed support.45(function nonStandardBrowserEnv() {46return {47write: function write() {},48read: function read() { return null; },49remove: function remove() {}50};51})()52);535455