1.0.1 • Published 10 years ago
ensure-string-endswith v1.0.1
ensure-string-endswith
Creates a function that appends a given character to a string, if (and only if) it does not already end with that character.
usage
var anyString = 'anyString',
stringEndingWithSlash = 'endsWith/',
ensureStringEndsWithSlash = ensureStringEndsWith('/');
ensureStringEndsWithSlash(anyString) === anyString + '/'; // true
ensureStringEndsWithSlash(stringEndingWithSlash) === stringEndingWithSlash; // true