UNPKG

@memori.ai/memori-react

Version:

[![npm version](https://img.shields.io/github/package-json/v/memori-ai/memori-react)](https://www.npmjs.com/package/@memori.ai/memori-react) ![Tests](https://github.com/memori-ai/memori-react/workflows/CI/badge.svg?branch=main) ![TypeScript Support](https

41 lines 1.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.sanitizeText = exports.escapeHTML = exports.stripOutputTags = exports.stripHTML = exports.stripEmojis = exports.stripMarkdown = void 0; function stripMarkdown(text) { return text .replace(/\*\*(.*?)\*\*/g, '$1') .replace(/\*(.*?)\*/g, '$1') .replace(/__(.*?)__/g, '$1') .replace(/_(.*?)_/g, '$1') .replace(/~~(.*?)~~/g, '$1') .replace(/```(.*?)```/gs, '$1') .replace(/`(.*?)`/g, '$1') .replace(/\[(.*?)\]\((.*?)\)/g, '$1'); } exports.stripMarkdown = stripMarkdown; function stripEmojis(text) { return text.replace(/[\u{1F600}-\u{1F64F}|\u{1F300}-\u{1F5FF}|\u{1F680}-\u{1F6FF}|\u{2600}-\u{26FF}|\u{2700}-\u{27BF}]/gu, ''); } exports.stripEmojis = stripEmojis; function stripHTML(text) { return text.replace(/<[^>]*>/g, ''); } exports.stripHTML = stripHTML; function stripOutputTags(text) { return text; } exports.stripOutputTags = stripOutputTags; function escapeHTML(text) { return text .replace(/&/g, '&amp;') .replace(/</g, '&lt;') .replace(/>/g, '&gt;') .replace(/"/g, '&quot;') .replace(/'/g, '&apos;'); } exports.escapeHTML = escapeHTML; function sanitizeText(text) { return escapeHTML(stripMarkdown(stripEmojis(stripHTML(stripOutputTags(text))))); } exports.sanitizeText = sanitizeText; //# sourceMappingURL=sanitizer.js.map