Gathering detailed insights and metrics for punycode
Gathering detailed insights and metrics for punycode
Gathering detailed insights and metrics for punycode
Gathering detailed insights and metrics for punycode
A robust Punycode converter that fully complies to RFC 3492 and RFC 5891.
npm install punycode
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
1,603 Stars
150 Commits
159 Forks
38 Watching
2 Branches
19 Contributors
Updated on 28 Nov 2024
Minified
Minified + Gzipped
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-8.5%
16,677,376
Compared to previous day
Last week
1.9%
100,551,539
Compared to previous week
Last month
16.8%
400,222,245
Compared to previous month
Last year
4.5%
4,054,028,884
Compared to previous year
Punycode.js is a robust Punycode converter that fully complies to RFC 3492 and RFC 5891.
This JavaScript library is the result of comparing, optimizing and documenting different open-source implementations of the Punycode algorithm:
punycode.c
by Markus W. Scherer (IBM)punycode.c
by Ben Noordhuispunycode.js
by Ben Noordhuis (note: not fully compliant)This project was bundled with Node.js from v0.6.2+ until v7 (soft-deprecated).
This project provides a CommonJS module that uses ES2015+ features and JavaScript module, which work in modern Node.js versions and browsers. For the old Punycode.js version that offers the same functionality in a UMD build with support for older pre-ES2015 runtimes, including Rhino, Ringo, and Narwhal, see v1.4.1.
Via npm:
1npm install punycode --save
In Node.js:
⚠️ Note that userland modules don't hide core modules. For example,
require('punycode')
still imports the deprecated core module even if you executednpm install punycode
. Userequire('punycode/')
to import userland modules rather than core modules.
1const punycode = require('punycode/');
punycode.decode(string)
Converts a Punycode string of ASCII symbols to a string of Unicode symbols.
1// decode domain name parts 2punycode.decode('maana-pta'); // 'mañana' 3punycode.decode('--dqo34k'); // '☃-⌘'
punycode.encode(string)
Converts a string of Unicode symbols to a Punycode string of ASCII symbols.
1// encode domain name parts 2punycode.encode('mañana'); // 'maana-pta' 3punycode.encode('☃-⌘'); // '--dqo34k'
punycode.toUnicode(input)
Converts a Punycode string representing a domain name or an email address to Unicode. Only the Punycoded parts of the input will be converted, i.e. it doesn’t matter if you call it on a string that has already been converted to Unicode.
1// decode domain names
2punycode.toUnicode('xn--maana-pta.com');
3// → 'mañana.com'
4punycode.toUnicode('xn----dqo34k.com');
5// → '☃-⌘.com'
6
7// decode email addresses
8punycode.toUnicode('джумла@xn--p-8sbkgc5ag7bhce.xn--ba-lmcq');
9// → 'джумла@джpумлатест.bрфa'
punycode.toASCII(input)
Converts a lowercased Unicode string representing a domain name or an email address to Punycode. Only the non-ASCII parts of the input will be converted, i.e. it doesn’t matter if you call it with a domain that’s already in ASCII.
1// encode domain names
2punycode.toASCII('mañana.com');
3// → 'xn--maana-pta.com'
4punycode.toASCII('☃-⌘.com');
5// → 'xn----dqo34k.com'
6
7// encode email addresses
8punycode.toASCII('джумла@джpумлатест.bрфa');
9// → 'джумла@xn--p-8sbkgc5ag7bhce.xn--ba-lmcq'
punycode.ucs2
punycode.ucs2.decode(string)
Creates an array containing the numeric code point values of each Unicode symbol in the string. While JavaScript uses UCS-2 internally, this function will convert a pair of surrogate halves (each of which UCS-2 exposes as separate characters) into a single code point, matching UTF-16.
1punycode.ucs2.decode('abc'); 2// → [0x61, 0x62, 0x63] 3// surrogate pair for U+1D306 TETRAGRAM FOR CENTRE: 4punycode.ucs2.decode('\uD834\uDF06'); 5// → [0x1D306]
punycode.ucs2.encode(codePoints)
Creates a string based on an array of numeric code point values.
1punycode.ucs2.encode([0x61, 0x62, 0x63]); 2// → 'abc' 3punycode.ucs2.encode([0x1D306]); 4// → '\uD834\uDF06'
punycode.version
A string representing the current Punycode.js version number.
On the main
branch, bump the version number in package.json
:
1npm version patch -m 'Release v%s'
Instead of patch
, use minor
or major
as needed.
Note that this produces a Git commit + tag.
Push the release commit and tag:
1git push && git push --tags
Our CI then automatically publishes the new release to npm, under both the punycode
and punycode.js
names.
Mathias Bynens |
Punycode.js is available under the MIT license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 13/30 approved changesets -- score normalized to 4
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More