Expands a URL that may or may not be relative to `base`.

@param {string} url
@param {string} base
@return {string}
function expandUrl(url, base) {
    if (!base)
        return url;
    if (url.match(/^(\/|https?:\/\/)/))
        return url;
    if (base.substr(base.length - 1) !== '/') {
        base = base + '/';
    }
    return base + url;
}