open-nomad/ui/app/utils/add-to-path.js
2019-05-20 11:52:47 -07:00

12 lines
283 B
JavaScript

// Adds a string to the end of a URL path while being mindful of query params
export default function addToPath(url, extension = '') {
const [path, params] = url.split('?');
let newUrl = `${path}${extension}`;
if (params) {
newUrl += `?${params}`;
}
return newUrl;
}