stripSuffix
Removes a suffix from a string if it exists.
stripSuffix
Signature
typescript
function stripSuffix(str: string, suffix: string): stringParameters
str- The string to stripsuffix- The suffix to remove
Returns
String without the suffix.
Examples
typescript
import { stripSuffix } from 'strio'
stripSuffix('Hello world', ' world')
// "Hello"
stripSuffix('test', 'foo')
// "test" (no change)Related Functions
- stripPrefix - Remove prefix
- ensureRight - Ensure suffix