combineURLs.js 385 B

1234567891011121314
  1. 'use strict'
  2. /**
  3. * Creates a new URL by combining the specified URLs
  4. *
  5. * @param {string} baseURL The base URL
  6. * @param {string} relativeURL The relative URL
  7. * @returns {string} The combined URL
  8. */
  9. export default function combineURLs(baseURL, relativeURL) {
  10. return relativeURL
  11. ? `${baseURL.replace(/\/+$/, '')}/${relativeURL.replace(/^\/+/, '')}`
  12. : baseURL
  13. }