Skip to content

Instantly share code, notes, and snippets.

@adamculpepper
Created October 28, 2015 19:50
Show Gist options
  • Save adamculpepper/0e3addeadaef4253a937 to your computer and use it in GitHub Desktop.
Save adamculpepper/0e3addeadaef4253a937 to your computer and use it in GitHub Desktop.
JavaScript: Strip Trailing Slash
function stripTrailingSlash(str) {
if(str.substr(-1) === '/') {
return str.substr(0, str.length - 1);
}
return str;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment