Created
March 11, 2022 10:30
-
-
Save AitorAlejandro/438c66d483641e0fdc624b5fd61a2d61 to your computer and use it in GitHub Desktop.
Removes the trailing slash of a string
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
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