"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.urlConcat = urlConcat;

/* eslint-disable no-use-before-define */

/**
 *
 * @param {String} url
 * @param {String} path
 */
function urlConcat(url, path) {
  const slashRemovedUrl = removeLastSlash(url);
  const slashRemovedPath = removeFrontSlash(path);

  if (slashRemovedUrl === '') {
    return path;
  }

  return `${slashRemovedUrl}/${slashRemovedPath}`;
}

function removeLastSlash(url) {
  return url.replace(/\/+$/, '');
}

function removeFrontSlash(url) {
  return url.replace(/^\/+/, '');
}