Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove url parameters using javascript

I would like this url:

http://bulk-click.startappsdasdasice.com/tracking/adClick?d=scsdc%20cdcsc%20c

to become

bulk-click.startappsdasdasice.com/tracking

I need this kind of pattern for all urls. so the string with the question mark and onward need to be deleted

like image 805
biillitil Avatar asked Mar 09 '26 04:03

biillitil


1 Answers

There are several ways for this one of them is

var url="http://bulk-click.startappsdasdasice.com/tracking/adClick?d=scsdc%20cdcsc%20c";
var suburl=url.substring(0,url.lastIndexOf("/")).replace(/(^\w+:|^)\/\//, '');
console.log(suburl);
like image 74
mr. pc_coder Avatar answered Mar 10 '26 17:03

mr. pc_coder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!