combineURLs.js 348 B

123456789101112
  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. module.exports = function combineURLs(baseURL, relativeURL) {
  10. return baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '');
  11. };