1.0.1 • Published 10 years ago

ensure-string-endswith v1.0.1

Weekly downloads
29
License
MIT
Repository
-
Last release
10 years ago

ensure-string-endswith

Travis

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