
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
decode-named-character-reference
Advanced tools
The decode-named-character-reference npm package is used to decode named character references (also known as HTML entities) into their corresponding characters. This is particularly useful when dealing with HTML or XML content where special characters are encoded as named entities.
Decode Named Character Reference
This feature allows you to decode a named character reference into its corresponding character. In this example, the named character reference '&' is decoded to '&'.
const decode = require('decode-named-character-reference');
const decodedString = decode('&');
console.log(decodedString); // Output: &
Decode Multiple Named Character References
This feature allows you to decode multiple named character references within a string. In this example, both '&' and '<' are decoded to '&' and '<' respectively.
const decode = require('decode-named-character-reference');
const decodedString = decode('Hello & welcome to the world of <coding>!');
console.log(decodedString); // Output: Hello & welcome to the world of <coding>!
The 'he' package (short for HTML entities) is a robust HTML entity encoder/decoder. It supports both named and numeric character references and can handle both encoding and decoding. Compared to decode-named-character-reference, 'he' offers more comprehensive functionality including encoding capabilities.
The 'entities' package provides fast and robust encoding and decoding of XML and HTML entities. It supports both named and numeric character references. Similar to 'he', it offers both encoding and decoding functionalities, making it more versatile than decode-named-character-reference.
The 'html-entities' package is another library for encoding and decoding HTML entities. It supports named, numeric, and hexadecimal character references. This package is similar to 'he' and 'entities' in terms of functionality, providing both encoding and decoding capabilities.
Decode named character references.
A workaround for webpack.
Never use this.
Use parse-entities
.
It uses this.
This package is ESM only. In Node.js (version 14.14+, 16.0+), install with npm:
npm install decode-named-character-reference
In Deno with esm.sh
:
import {decodeNamedCharacterReference} from 'https://esm.sh/decode-named-character-reference@1'
In browsers with esm.sh
:
<script type="module">
import {decodeNamedCharacterReference} from 'https://esm.sh/decode-named-character-reference@1?bundle'
</script>
import {decodeNamedCharacterReference} from 'decode-named-character-reference'
decodeNamedCharacterReference('amp') //=> '&'
This package exports the identifier decodeNamedCharacterReference
.
There is no default export.
decodeNamedCharacterReference(value)
Again, use parse-entities
.
This package is fully typed with TypeScript. It exports no additional types.
This package is at least compatible with all maintained versions of Node.js. As of now, that is Node.js 14.14+ and 16.0+. It also works in Deno and modern browsers.
This package is safe.
parse-entities
— parse (decode) HTML character referencesYes please! See How to Contribute to Open Source.
FAQs
Decode named character references
The npm package decode-named-character-reference receives a total of 8,052,515 weekly downloads. As such, decode-named-character-reference popularity was classified as popular.
We found that decode-named-character-reference demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.