Skip to content

ensurePrefix

Ensure that a prefix exists in the string, and add it if it does not exist

Usage

ts
import { ensurePrefix } from 'rattail'

ensurePrefix('prefix-hello-world', 'prefix-') // return 'prefix-hello-world'
ensurePrefix('hello-world', 'prefix-') // return 'prefix-hello-world'

Arguments

ArgTypeDefaults
valuestring
prefixstring

Return

Type
string