@juntoz/str-bounds
Version:
Utility to add or remove a character from the start or end of a string. Useful to build a url, query, etc.
24 lines (17 loc) • 448 B
Markdown
Utility library to add or remove a character from the start or end of a string.
Useful to build urls, queries, etc.
```
npm install @juntoz/str-bounds
```
```
const bounds = require('@juntoz/str-bounds');
var urlpath = 'mypath';
bounds.ensureInitSlash(urlpath);
// => /mypath
var urlhost = 'http://github.com';
bounds.ensureFinalSlash(urlhost);
// => http://github.com/
```