JSFiddle - React, Tailwind, and code Playground

by angstrey

JavaScript

var ApplicationRoot = "/avdifr";

function ResolveUrl(relativeUrl) {
    var resolvedUrl;

    if (relativeUrl.indexOf("../") == 0) {
        resolvedUrl = ApplicationRoot + relativeUrl.substring(2, relativeUrl.length); ;
    }
    else if (relativeUrl.indexOf("/") == 0) {
        resolvedUrl = ApplicationRoot + relativeUrl;
    }
    else if (relativeUrl.indexOf("~/") == 0) {
        resolvedUrl = ApplicationRoot + relativeUrl.substring(1, relativeUrl.length);
    }
    else {
        resolvedUrl = relativeUrl;
    }

    return resolvedUrl;
}

alert(ResolveUrl("~/Content/favicons"));