-1


I want to get the parameters after slash in the url. For example the facebook profile url is like this https://www.facebook.com/username
I want to get username parameter from the url and act on it. I am sorry if its a duplicate question or not but I could not find the solution for it anywhere.

Thanks in advance!

Mars Moon
  • 94
  • 2
  • 14
  • 3
    Possible duplicate of [Last segment of URL](https://stackoverflow.com/questions/4758103/last-segment-of-url) – David R Oct 30 '18 at 07:20

1 Answers1

1

You can do split('/').pop() with backslash:

var url = 'https://www.facebook.com/username';
var username = url.split('/').pop();
console.log(username);
Ankit Agarwal
  • 30,378
  • 5
  • 37
  • 62