Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ module.exports = {
"testPathIgnorePatterns": [
"cypress/integration/standalone.spec.js"
]
,
};
32 changes: 19 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
"author": "Jigar Dafda<[email protected]>",
"license": "ISC",
"dependencies": {
"axios": "^0.27.2",
"axios": "^1.6.4",
"camelcase": "^6.3.0",
"crypto-js": "^4.1.1",
"crypto-js": "^4.2.0",
"isomorphic-base64": "^1.0.2",
"joi": "^17.7.0",
"loglevel": "^1.8.1",
Expand Down
3 changes: 1 addition & 2 deletions sdk/common/AxiosHelper.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const combineURLs = require("axios/lib/helpers/combineURLs");
const isAbsoluteURL = require("axios/lib/helpers/isAbsoluteURL");
const { combineURLs, isAbsoluteURL } = require("./Utility");
const axios = require("axios");
const querystring = require("query-string");
const { sign } = require("./RequestSigner");
Expand Down
32 changes: 32 additions & 0 deletions sdk/common/Utility.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,39 @@ function convertActionToUrl(action) {
}
}

// kept same as axios function
/**
* Determines whether the specified URL is absolute
*
* @param {string} url The URL to test
*
* @returns {boolean} True if the specified URL is absolute, otherwise false
*/
function isAbsoluteURL(url) {
// A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
// RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
// by any combination of letters, digits, plus, period, or hyphen.
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
}

/**
* Creates a new URL by combining the specified URLs
*
* @param {string} baseURL The base URL
* @param {string} relativeURL The relative URL
*
* @returns {string} The combined URL
*/
function combineURLs(baseURL, relativeURL) {
return relativeURL
? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
: baseURL;
}


module.exports = {
convertActionToUrl,
convertUrlToAction,
isAbsoluteURL,
combineURLs
};
3 changes: 1 addition & 2 deletions sdk/common/curlHelper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const qs = require("query-string");
const combineURLs = require("axios/lib/helpers/combineURLs");
const isAbsoluteURL = require("axios/lib/helpers/isAbsoluteURL");
const { combineURLs, isAbsoluteURL } = require("./Utility");

let reqConfig;

Expand Down