Skip to content

Instantly share code, notes, and snippets.

@boy3vil
Created April 18, 2015 04:49
Show Gist options
  • Select an option

  • Save boy3vil/b7de7ff3b07de7ee5654 to your computer and use it in GitHub Desktop.

Select an option

Save boy3vil/b7de7ff3b07de7ee5654 to your computer and use it in GitHub Desktop.
jquery parse clean URL
var url = 'example.com/hello/world/20111020/';
//get rid of the trailing / before doing a simple split on /
var url_parts = url.replace(/\/\s*$/,'').split('/');
//since we do not need example.com
url_parts.shift();
Now url_parts will point to the array ["hello", "world", "20111020"].
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment