I need to obtain parameter values from url string
http://example.com/admin/param1/value1/param2/value2
I did it already using this:
url.split('/param1/')[1].split('/')[0].replace(/\/$/, '');
But is there any cleaner alternative ? Something like this ?
var url_string = "http://www.example.com/t.html?a=1&b=3&c=m2-m3-m4-m5"; //window.location.href
var url = new URL(url_string);
var c = url.searchParams.get("c");
console.log(c);
searchParams
don't give desired results in this case. Pardon if there is already an answer out there. I couldn't find.
Please read the question carefully before marking it as duplicate.