axios-axios/lib/core/buildFullPath.js
Gabe Mendoza 02c3c69ced
fix: backport allowAbsoluteUrls vuln fix to v0.x (#6829)
* allowAbsoluteUrls

* fix logic - copied from v1.x

* update string

* undo changes to dist/axios.js

* chore: use strict equal in lib/core/buildFullPath.js

---------

Co-authored-by: Jay <jasonsaayman@gmail.com>
2025-03-19 12:24:25 +02:00

24 lines
860 B
JavaScript

'use strict';
var isAbsoluteURL = require('../helpers/isAbsoluteURL');
var combineURLs = require('../helpers/combineURLs');
/**
* Creates a new URL by combining the baseURL with the requestedURL,
* only when the requestedURL is not already an absolute URL.
* If the requestURL is absolute, this function returns the requestedURL untouched.
*
* @param {string} baseURL The base URL
* @param {string} requestedURL Absolute or relative URL to combine
* @param {boolean} allowAbsoluteUrls Set to true to allow absolute URLs
*
* @returns {string} The combined full path
*/
module.exports = function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
var isRelativeURL = !isAbsoluteURL(requestedURL);
if (baseURL && (isRelativeURL || allowAbsoluteUrls === false)) {
return combineURLs(baseURL, requestedURL);
}
return requestedURL;
};