function pathJoin(...parts) {
    // https://stackoverflow.com/a/55142565
    parts = parts.map((part, index) => {
        if (index) {
            part = part.replace(new RegExp('^/'), '');
        }
        if (index !== parts.length - 1) {
            part = part.replace(new RegExp('/$'), '');
        }
        return part;
    })
    return parts.join('/');
}
Joins multiple parts of a path into a single path, while handling leading and trailing slashes.

@param {...string} parts Multiple parts of a path.
@returns {string} A string representing the joined path.