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.

15 lines
382 B

1 month ago
  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. *
  8. * @returns {string} The combined URL
  9. */
  10. export default function combineURLs(baseURL, relativeURL) {
  11. return relativeURL
  12. ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '')
  13. : baseURL;
  14. }