🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

@king-one/axios-extend

Package Overview
Dependencies
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@king-one/axios-extend - npm Package Compare versions

Comparing version

to
1.0.6

6

CHANGELOG.md
# @king-one/axios-extend
## 1.0.6
### Patch Changes
- feat:增加请求参数接口
## 1.0.5

@@ -4,0 +10,0 @@

34

dist/lib/src/prefix/index.js

@@ -5,22 +5,26 @@ "use strict";

let prefixPromise = null;
const { getPrefix, prefixCall, ignoreUrls = [] } = options;
const { getPrefix, prefixCall } = options;
axios.interceptors.request.use(async (config) => {
let prefix = getPrefix();
if (!prefix && !ignoreUrls.includes(config.url || "")) {
if (!prefixPromise) {
const result = prefixCall();
prefixPromise = result instanceof Promise ? result : Promise.resolve();
prefixPromise.finally(() => {
prefixPromise = null;
});
if (!config.isPrefix) {
return config;
} else {
let prefix = getPrefix();
if (!prefix) {
if (!prefixPromise) {
const result = prefixCall();
prefixPromise = result instanceof Promise ? result : Promise.resolve();
prefixPromise.finally(() => {
prefixPromise = null;
});
}
await prefixPromise;
prefix = getPrefix();
}
await prefixPromise;
prefix = getPrefix();
if (prefix && config.url) {
config.url = prefix.startsWith("/") ? `${prefix}${config.url}` : `/${prefix}${config.url}`;
}
return config;
}
if (prefix && config.url) {
config.url = prefix.startsWith("/") ? `${prefix}${config.url}` : `/${prefix}${config.url}`;
}
return config;
});
}
exports.axiosPrefix = axiosPrefix;

@@ -1,7 +0,9 @@

import { AxiosInstance } from 'axios';
import { AxiosInstance, InternalAxiosRequestConfig } from 'axios';
export interface AxiosPrefixOpstions {
getPrefix: () => string | undefined | null;
prefixCall: () => void | Promise<void>;
ignoreUrls?: string[];
}
export interface PrefixAxiosRequestConfig extends InternalAxiosRequestConfig {
isPrefix?: boolean;
}
export declare function axiosPrefix(axios: AxiosInstance, options: AxiosPrefixOpstions): void;
{
"name": "@king-one/axios-extend",
"version": "1.0.5",
"version": "1.0.6",
"description": "",

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

Sorry, the diff of this file is not supported yet