meblog
Version:
A simple blog engine for personal blogging
30 lines (29 loc) • 782 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
class StringUtils {
static collectTags(source) {
if (typeof source === 'string') {
source = [source];
}
const tags = source
.filter((t) => t)
.flatMap((s) => s)
.map((s) => String(s))
.flatMap((s) => s.split(/[\s,]/gm))
.filter((t) => t);
return Array.from(new Set(tags));
}
static capitalize(str) {
if (!str) {
return '';
}
return str.charAt(0).toUpperCase() + str.substring(1);
}
static trimSlashes(str) {
if (!str) {
return '';
}
return str.replace(/^\/|\/$/gm, '');
}
}
exports.default = StringUtils;