Skip to content

Instantly share code, notes, and snippets.

@AitorAlejandro
Created March 11, 2022 10:30
Show Gist options
  • Save AitorAlejandro/438c66d483641e0fdc624b5fd61a2d61 to your computer and use it in GitHub Desktop.
Save AitorAlejandro/438c66d483641e0fdc624b5fd61a2d61 to your computer and use it in GitHub Desktop.
Removes the trailing slash of a string
const removeTrailingSlash = (value: string): string => value && value.charAt(value.length - 1) === '/' ? value.slice(0, -1) : value;
removeTrailingSlash('foo-bar/'); // -> foo-bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment