@rashedmakkouk/dev-utils
Version:
Utility library.
22 lines (21 loc) • 712 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
/** Utilities */
const trim_whitespace_1 = __importDefault(require("./trim-whitespace"));
/**
* Trims extra whitespace and removes HTML tags.
*
* @returns Sanitized string.
*/
function sanitize(text) {
text = (0, trim_whitespace_1.default)(text)
/** Removes html tags; TODO remove ^. */
.replace(/(<([^>]+)>)/gi, '')
/** Removes leading and trailing spaces. */
.trim();
return !text.replace(/\s/g, '').length ? '' : text;
}
exports.default = sanitize;