export function getTargetUrlForDeployingWar()

in src/tasks/tomcatDeployment/tomcatDeployment.ts [33:49]


export function getTargetUrlForDeployingWar(tomcatUrl: string, warfile: string, context: string, serverVersion: string): string {
    if (context.charAt(0) != "/") {
        tl.error("Invalid context. Context should start with '/'");
        tl.exit(1);
    }
    
    var warfileBaseName = path.basename(warfile.replace("\\\\", "\\"), ".war"); // basename doesn't work with \\\\share\\file.war but works with \\sahre\\file.war
    var context = (context == "/") ? context + warfileBaseName : context;
    context = encodeURIComponent(context).replace(/%2F/g, "/"); // encode all characters like space and '&'. Exclude '/' for readability
    
    if (serverVersion == "6.x") {
        return tomcatUrl + "/manager/deploy?path=" + context + "&update=true";
    }
    else {
        return tomcatUrl + "/manager/text/deploy?path=" + context + "&update=true";        
    }
}