본문 바로가기

Web Dev

Node.js -web : sanitize-html

반응형

C:\>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help init` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (nodejs)
version: (1.0.0)
description:
entry point: (main.js)
test command:
git repository: (https://github.com/Centumjoonho/nodejs)
keywords:
author:
license: (ISC)
About to write to C:\nodejs\package.json:

{
  "name": "nodejs",
  "version": "1.0.0",
  "description": "",
  "main": "main.js",
  "directories": {
    "lib": "lib"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Centumjoonho/nodejs.git"
  },
  "author": "",
  "license": "ISC",
  "bugs": {
    "url": "https://github.com/Centumjoonho/nodejs/issues"
  },
  "homepage": "https://github.com/Centumjoonho/nodejs#readme"
}


Is this OK? (yes)

C:\nodejs>

C:\nodejs>npm install -S sanitize-html

added 15 packages, and audited 16 packages in 3s

8 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

https://www.npmjs.com/package/sanitize-html

 

sanitize-html

Clean up user-submitted HTML, preserving allowlisted elements and allowlisted attributes on a per-element basis. Latest version: 2.7.0, last published: 3 months ago. Start using sanitize-html in your project by running `npm i sanitize-html`. There are 1269

www.npmjs.com

var sanitizeHTML = require("sanitize-html");
var sanitizedTitle =sanitizeHTML(title);
var sanitizedDescription = sanitizeHTML(description,{allowedTags:['h1']});

 

반응형