How to compare two urls in javascript or jquery - Stack Overflow

PHOTO EMBED

Thu Mar 31 2022 11:38:02 GMT+0000 (Coordinated Universal Time)

Saved by @Minhow

function getDomain(url) {
    var prefix = /^https?:\/\//i;
    var domain = /^[^\/:]+/;
    // remove any prefix
    url = url.replace(prefix, "");
    // assume any URL that starts with a / is on the current page's domain
    if (url.charAt(0) === "/") {
        url = window.location.hostname + url;
    }
    // now extract just the domain
    var match = url.match(domain);
    if (match) {
        return(match[0]);
    }
    return(null);
}
content_copyCOPY

https://stackoverflow.com/questions/12220345/how-to-compare-two-urls-in-javascript-or-jquery