Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cn-request

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cn-request - npm Package Compare versions

Comparing version 1.0.31 to 1.0.32

22

dist/index.js

@@ -92,2 +92,16 @@ (function (global, factory) {

}
function getCookie(cookieName) {
var allCookies = window.document.cookie;
var cookiePos = allCookies.indexOf(cookieName);
var cookieVal = "";
if (cookiePos != -1) {
cookiePos = cookiePos + cookieName.length + 1;
var cookieEnd = allCookies.indexOf(";", cookiePos);
if (cookieEnd == -1) {
cookieEnd = allCookies.length;
}
cookieVal = allCookies.substring(cookiePos, cookieEnd);
}
return cookieVal;
}

@@ -194,2 +208,10 @@ var LEGAL_METHODS = ["GET", "POST"];

var axiosInstance = axios.create(axiosConfig);
try {
var xsrfToken = getCookie('XSRF-TOKEN');
if (!xsrfToken) {
axiosInstance.defaults.headers.common['X-XSRF-TOKEN'] = xsrfToken;
}
}
catch (error) {
}
axiosInstance.interceptors.request.use(function (config) {

@@ -196,0 +218,0 @@ try {

2

package.json
{
"name": "cn-request",
"version": "1.0.31",
"version": "1.0.32",
"description": "菜鸟前端统一请求库",

@@ -5,0 +5,0 @@ "author": "牛尔",

@@ -11,3 +11,3 @@ /**

} from "axios";
import { isUndefined, armsTraceLog, mergeReportData } from "./utils";
import { isUndefined, armsTraceLog, mergeReportData, getCookie } from "./utils";
import {

@@ -185,2 +185,13 @@ CnOptions,

const axiosInstance: AxiosInstance = axios.create(axiosConfig);
// 全局 xsrfToken 处理
try {
const xsrfToken = getCookie('XSRF-TOKEN');
if(!xsrfToken){
axiosInstance.defaults.headers.common['X-XSRF-TOKEN'] = xsrfToken;
}
} catch (error) {
}
axiosInstance.interceptors.request.use(

@@ -187,0 +198,0 @@ (config: AxiosRequestConfig) => {

@@ -80,2 +80,18 @@ import { AxiosResponse } from "axios";

export { isUndefined, mergeReportData, armsTraceLog };
function getCookie(cookieName: string): string {
const allCookies: string = window.document.cookie;
let cookiePos = allCookies.indexOf(cookieName);
let cookieVal = "";
if (cookiePos != -1) {
cookiePos = cookiePos + cookieName.length + 1;
let cookieEnd = allCookies.indexOf(";", cookiePos);
if (cookieEnd == -1) {
cookieEnd = allCookies.length;
}
cookieVal = allCookies.substring(cookiePos, cookieEnd);
}
return cookieVal;
}
export { isUndefined, mergeReportData, armsTraceLog, getCookie };
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc