UNPKG

@rashedmakkouk/dev-utils

Version:
22 lines (21 loc) 712 B
"use strict"; 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;