function rewriteHrefBaseUrl(href, oldBaseUrl, newBaseUrl) {
    if (isAbsolutePath(href)) {
        return href;
    }
    const absUrl = url.resolve(oldBaseUrl, href);
    const parsedFrom = url.parse(newBaseUrl);
    const parsedTo = url.parse(absUrl);
    if (parsedFrom.protocol === parsedTo.protocol &&
        parsedFrom.host === parsedTo.host) {
        let dirFrom = path.posix.dirname(
        // Have to append a '_' to the path because path.posix.dirname('foo/')
        // returns '.' instead of 'foo'.
        parsedFrom.pathname ? parsedFrom.pathname + '_' : '');
        let pathTo = parsedTo.pathname || '';
        if (isAbsolutePath(oldBaseUrl) || isAbsolutePath(newBaseUrl)) {
            dirFrom = makeAbsolutePath(dirFrom);
            pathTo = makeAbsolutePath(pathTo);
        }
        const pathname = pathPosixRelative(dirFrom, pathTo);
        return url.format({ pathname: pathname, search: parsedTo.search, hash: parsedTo.hash });
    }
    return absUrl;
}
/**
 * Modifies an href by the relative difference between the old base url and
 * the new base url.
 */
Modifies an href by the relative difference between the old base url and
the new base url.
Modifies an href by the relative difference between the old base url and the new base url .
function rewriteHrefBaseUrl(href, oldBaseUrl, newBaseUrl) {
    if (isAbsolutePath(href)) {
        return href;
    }
    const absUrl = url.resolve(oldBaseUrl, href);
    const parsedFrom = url.parse(newBaseUrl);
    const parsedTo = url.parse(absUrl);
    if (parsedFrom.protocol === parsedTo.protocol &&
        parsedFrom.host === parsedTo.host) {
        let dirFrom = path.posix.dirname(
        parsedFrom.pathname ? parsedFrom.pathname + '_' : '');
        let pathTo = parsedTo.pathname || '';
        if (isAbsolutePath(oldBaseUrl) || isAbsolutePath(newBaseUrl)) {
            dirFrom = makeAbsolutePath(dirFrom);
            pathTo = makeAbsolutePath(pathTo);
        }
        const pathname = pathPosixRelative(dirFrom, pathTo);
        return url.format({ pathname: pathname, search: parsedTo.search, hash: parsedTo.hash });
    }
    return absUrl;
}
function rewriteHrefBaseUrl ( href , oldBaseUrl , newBaseUrl ) { if ( isAbsolutePath ( href ) ) { return href ; } const absUrl = url . resolve ( oldBaseUrl , href ) ; const parsedFrom = url . parse ( newBaseUrl ) ; const parsedTo = url . parse ( absUrl ) ; if ( parsedFrom . protocol === parsedTo . protocol && parsedFrom . host === parsedTo . host ) { let dirFrom = path . posix . dirname ( parsedFrom . pathname ? parsedFrom . pathname + '_' : '' ) ; let pathTo = parsedTo . pathname || '' ; if ( isAbsolutePath ( oldBaseUrl ) || isAbsolutePath ( newBaseUrl ) ) { dirFrom = makeAbsolutePath ( dirFrom ) ; pathTo = makeAbsolutePath ( pathTo ) ; } const pathname = pathPosixRelative ( dirFrom , pathTo ) ; return url . format ( { pathname : pathname , search : parsedTo . search , hash : parsedTo . hash } ) ; } return absUrl ; }
Modifies an href by the relative difference between the old base url and
 the new base url.
Modifies an href by the relative difference between the old base url and the new base url .
// Have to append a '_' to the path because path.posix.dirname('foo/') // returns '.' instead of 'foo'.