You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
695 B

  1. 'use strict';
  2. var isAbsoluteURL = require('../helpers/isAbsoluteURL');
  3. var combineURLs = require('../helpers/combineURLs');
  4. /**
  5. * Creates a new URL by combining the baseURL with the requestedURL,
  6. * only when the requestedURL is not already an absolute URL.
  7. * If the requestURL is absolute, this function returns the requestedURL untouched.
  8. *
  9. * @param {string} baseURL The base URL
  10. * @param {string} requestedURL Absolute or relative URL to combine
  11. * @returns {string} The combined full path
  12. */
  13. module.exports = function buildFullPath(baseURL, requestedURL) {
  14. if (baseURL && !isAbsoluteURL(requestedURL)) {
  15. return combineURLs(baseURL, requestedURL);
  16. }
  17. return requestedURL;
  18. };