Amit Dhamu

Software Engineer

Get Query Parameters

// Returns object
function getQueryParams(url) {
    return url.replace(/(.*\?)/, '').split('&').map(function(n) {
        return n = n.split('='), this[n[0]] = n[1], this
    }.bind({}))[0];
}

// Usage
var url = 'http://www.google.co.uk?lang=en&q=foo';
console.log(getQueryParams(url));

// Result
{
    lang: "en",
    q: "foo"
}

 query / params / url

Escape HTMLRedirect to https & non-www in NGINX

Show Comments

Made with by Amit Dhamu.
© MMXX. All rights reserved.