Skip to content

Instantly share code, notes, and snippets.

@ranwahle
Created May 12, 2019 11:35
Show Gist options
  • Save ranwahle/073a751dfae1cc8cc1d1c7e7e04377dc to your computer and use it in GitHub Desktop.
Save ranwahle/073a751dfae1cc8cc1d1c7e7e04377dc to your computer and use it in GitHub Desktop.
Get fragments
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