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
701 B

3 years ago
  1. 'use strict'
  2. import isAbsoluteURL from '../helpers/isAbsoluteURL'
  3. import combineURLs from '../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. export default function buildFullPath(baseURL, requestedURL) {
  14. if (baseURL && !isAbsoluteURL(requestedURL)) {
  15. return combineURLs(baseURL, requestedURL)
  16. }
  17. return requestedURL
  18. }