function appendToURLPath(url, name) {
    const urlParsed = new URL(url);
    let path = urlParsed.pathname;
    path = path ? (path.endsWith("/") ? `${path}${name}` : `${path}/${name}`) : name;
    urlParsed.pathname = path;
    return urlParsed.toString();
}
Append a string to URL path. Will remove duplicated "/" in front of the string
when URL path ends with a "/".

@param url - Source URL string
@param name - String to be appended to URL
@returns An updated URL string