Created
April 18, 2015 04:49
-
-
Save boy3vil/b7de7ff3b07de7ee5654 to your computer and use it in GitHub Desktop.
jquery parse clean URL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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