Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

sanitize

import { sanitize } from "https://lilk6errxype3gpzga773pqnv4zzvc2v7locw2phzged227jyamq.arweave.net/WhavEjG-Hk2Z-TA__b4NrzOai1X63Ctp58mIPWvpwBk/mod.ts";

Sanitize &, <, > and " in string.

function sanitize(str?, { amp, lt, gt, quot }?: Record<string, boolean>): string;
§
sanitize(str?, { amp, lt, gt, quot }?: Record<string, boolean>): string
[src]

§Parameters

§
str? optional
[src]
§
{ amp, lt, gt, quot }?: Record<string, boolean> optional
[src]

§Return Type

§
string
[src]

sanitized string

Use SanitizeOption like { amp: false } to ignore sanitizing.

Examples:

import { sanitize } from "https://deno.land/x/markup_tag/mod.ts";
import { assertEquals } from "https://deno.land/std/testing/asserts.ts"

// common usage
assertEquals(
sanitize(`<img src="https://www.example.com?width=10&height=10">`),
"&lt;img src=&quot;https://www.example.com?width=10&amp;height=10&quot;&gt;",
);

// ignore sanitizing specific characters
assertEquals(sanitize("<br>", { lt: false, gt: false }), "<br>");