@technobuddha/library
Version:
A large library of useful functions
12 lines (11 loc) • 319 B
JavaScript
/**
* Add a prefix to a string, if it does not already have the prefix
*
* @param input The string
* @param prefix The prefix
* @returns The prefix followed by the string
*/
export function ensurePrefix(input, prefix) {
return input.startsWith(prefix) ? input : prefix + input;
}
export default ensurePrefix;