Created
May 12, 2019 11:35
-
-
Save ranwahle/073a751dfae1cc8cc1d1c7e7e04377dc to your computer and use it in GitHub Desktop.
Get fragments
This file contains 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
getFragments(url) { | |
if (url.endsWith('/')) { | |
url = url.substring(0, url.length - 1); | |
} | |
if (url.startsWith('/')) { | |
url = url.substring(1); | |
} | |
return url === '/' ? [''] : url.split('/'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment