Created
August 28, 2014 19:54
-
-
Save Opus1no2/6f71d90ba330ca6a6833 to your computer and use it in GitHub Desktop.
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 pathRay = window.location.pathname.split('/'); | |
// Make sure that split returns | |
// an array of at least 2 values | |
// the value we want will be the 2nd value | |
if (pathRay.length >= 2) { | |
var firstRoute = pathRay[1]; | |
} | |
// Make sure the second value | |
// is not an empty string | |
if (firstRoute.length > 0) { | |
// Now we know for sure that the | |
// window location contains a non empty | |
// value such as http://foo.com/bar | |
// where 'bar' is the value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment