Skip to content

Commit b3f3503

Browse files
committed
v4.1.1
1 parent b9ba707 commit b3f3503

File tree

5 files changed

+42
-9
lines changed

5 files changed

+42
-9
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.1.1
2+
3+
- Updated `axios` to `1.7.7`.
4+
15
## 4.1.0
26

37
- Added [upload](./README.md#upload) method.

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ module.exports = {
1010
lines: 0,
1111
},
1212
},
13+
moduleNameMapper: {
14+
"^axios$": "axios/dist/node/axios.cjs",
15+
},
1316
};

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@pixelbin/admin",
3-
"version": "4.1.0",
3+
"version": "4.1.1",
44
"description": "Pixelbin Backend SDK for Javascript",
55
"main": "index.js",
66
"scripts": {
@@ -14,8 +14,8 @@
1414
"author": "Pixelbin",
1515
"license": "MIT",
1616
"dependencies": {
17-
"axios": "0.21.4",
18-
"crypto-js": "^4.2.0",
17+
"axios": "1.7.7",
18+
"crypto-js": "4.2.0",
1919
"joi": "17.4.0",
2020
"query-string": "7.1.3",
2121
"camelcase": "6.2.0",

sdk/common/AxiosHelper.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,37 @@
1-
const combineURLs = require("axios/lib/helpers/combineURLs");
2-
const isAbsoluteURL = require("axios/lib/helpers/isAbsoluteURL");
3-
const axios = require("axios");
1+
const { default: axios } = require("axios");
42
const querystring = require("query-string");
53
const { sign } = require("./RequestSigner");
64
const { PDKServerResponseError } = require("./PDKError");
75
const FormData = require("form-data");
86

7+
/**
8+
* https://github.com/axios/axios/blob/5b8a826771b77ab30081d033fdba9ef3b90e439a/lib/helpers/isAbsoluteURL.js
9+
* Determines whether the specified URL is absolute
10+
* @ignore
11+
* @param {string} url The URL to test
12+
* @returns {boolean} True if the specified URL is absolute, otherwise false
13+
*/
14+
function isAbsoluteURL(url) {
15+
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
16+
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
17+
// by any combination of letters, digits, plus, period, or hyphen.
18+
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
19+
}
20+
21+
/**
22+
* https://github.com/axios/axios/blob/5b8a826771b77ab30081d033fdba9ef3b90e439a/lib/helpers/combineURLs.js
23+
* Creates a new URL by combining the specified URLs
24+
* @ignore
25+
* @param {string} baseURL The base URL
26+
* @param {string} relativeURL The relative URL
27+
* @returns {string} The combined URL
28+
*/
29+
function combineURLs(baseURL, relativeURL) {
30+
return relativeURL
31+
? baseURL.replace(/\/+$/, "") + "/" + relativeURL.replace(/^\/+/, "")
32+
: baseURL;
33+
}
34+
935
axios.defaults.withCredentials = true;
1036

1137
function transformRequestOptions(params) {
@@ -115,7 +141,7 @@ function userAgentInterceptor(options) {
115141
return (config) => {
116142
const sdk = {
117143
name: "@pixelbin/admin",
118-
version: "4.1.0",
144+
version: "4.1.1",
119145
};
120146
const language = "JavaScript";
121147

tests/utils/user-agent.spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe("User-Agent Header Test", () => {
3939
it("should correctly set the User-Agent header incase no integerationPlatform is set", async () => {
4040
const userAgentInterceptor = pdkAxios.interceptors.request.handlers[0].fulfilled;
4141
const config = await userAgentInterceptor({ headers: {} });
42-
let userAgent = `@pixelbin/admin/4.1.0 (JavaScript)`;
42+
let userAgent = `@pixelbin/admin/4.1.1 (JavaScript)`;
4343
expect(config.headers["user-agent"]).toEqual(userAgent);
4444
});
4545

@@ -48,7 +48,7 @@ describe("User-Agent Header Test", () => {
4848
const interceptedConfig = await userAgentInterceptor({
4949
headers: { "user-agent": "Erasebg Plugin/1.2.3 (Figma/3.2.1)" },
5050
});
51-
let userAgent = `Erasebg Plugin/1.2.3 (Figma/3.2.1) @pixelbin/admin/4.1.0 (JavaScript)`;
51+
let userAgent = `Erasebg Plugin/1.2.3 (Figma/3.2.1) @pixelbin/admin/4.1.1 (JavaScript)`;
5252
expect(interceptedConfig.headers["user-agent"]).toEqual(userAgent);
5353
});
5454
});

0 commit comments

Comments
 (0)