Removes trailing slashes from a given string.
Here is a simple example:
removeTrailingSlash("https://example.com/")// => { ok: true, value: 'http://example.com' }removeTrailingSlash("https://example.com/path/")// => { ok: true, value: 'https://example.com/path' } Copy
removeTrailingSlash("https://example.com/")// => { ok: true, value: 'http://example.com' }removeTrailingSlash("https://example.com/path/")// => { ok: true, value: 'https://example.com/path' }
Handling non-string input:
removeTrailingSlash(42)// => { ok: false, error: Error('[strings.removeTrailingSlash] Expected string value as input') } Copy
removeTrailingSlash(42)// => { ok: false, error: Error('[strings.removeTrailingSlash] Expected string value as input') }
The string to remove trailing slashes from.
A Result object with either the modified string on success, or an Error object if the provided input is not a string.
Result
Error
Generated using TypeDoc v0.24.7
Removes trailing slashes from a given string.
Example
Here is a simple example:
Example
Handling non-string input: