Get URL Data

Retrieves GET parameters from URL string.

JavaScript

//get_url_data :)

function get_url_data(hash){   
    var e,
        a = /\+/g,
        r = /([^&=]+)=?([^&]*)/g,
        d = function (s) {
            return decodeURIComponent(s.replace(a, " "));
        },
        q = hash.split("?"),
        g = {};
    while (e = r.exec(q[1]))
        g[d(e[1])] = d(e[2]);
    return g;
}

//example useage

var GET = get_url_data("https://steamcommunity.com/openid/login?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=checkid_setup&openid.return_to=http%3A%2F%2Flocalhost%3A8000%2Flogin%2Fcallback%2Fsteam&openid.realm=http%3A%2F%2Flocalhost%3A8000&openid.ns.sreg=http%3A%2F%2Fopenid.net%2Fextensions%2Fsreg%2F1.1&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select");



var GET2 = get_url_data(" http://localhost:8000/login/callback/steam?openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fsteamcommunity.com%2Fopenid%2Flogin&openid.claimed_id=https%3A%2F%2Fsteamcommunity.com%2Fopenid%2Fid%2F76561198004640945&openid.identity=https%3A%2F%2Fsteamcommunity.com%2Fopenid%2Fid%2F76561198004640945&openid.return_to=http%3A%2F%2Flocalhost%3A8000%2Flogin%2Fcallback%2Fsteam&openid.response_nonce=2018-11-07T00%3A15%3A31ZhkvN78CTmph%2BT7u1uFWojSbKEBs%3D&openid.assoc_handle=1234567890&openid.signed=signed%2Cop_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle&openid.sig=Klq%2BL8l7R38IUVwhKrxKUr03%2FTA%3D");



for (item in GET) {
    document.write(item, " = ", GET[item], "<br/>");
}
echo "<br/>";
for (item in GET2) {
    document.write(item, " = ", GET2[item], "<br/>");
}