Reputation: 565
Hi my URL is like http://example.net/hi-how-are-you. I want to convert this URL as http://example.net//hi-how-are-you that is converting by last single slash sign with double slash sign.
I want my last slash of URL with double slash with java script / J query.
http://example.net/hi-how-are-you
http://example.net//hi-how-are-you
Upvotes: 0
Views: 139
Reputation: 17943
I am not sure why you want to do that, but following code will work for you.
var url = 'http://example.net/hi-how-are-you';
var pos = url.lastIndexOf('/');
url = url.substring(0,pos)+'//'+url.substring(pos+1);
console.log(url);
Upvotes: 1