Package Exports
- @adraffy/ens-normalize
- @adraffy/ens-normalize/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@adraffy/ens-normalize) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
ens-normalize.js
1-file, 1-function, 1-argument, 0-dependancy Compact ES6 Ethereum Name Service (ENS) Name Normalizer.
- Currently using experimental ideas!
- Uses Unicode v14.0.0
- Uses UTS-46 w/IDNA2008
- Uses UTS-51
- Handles
ContextJ
- Handles
ContextO
- Handles Emoji ZWJ Sequences
- Handles Punycode, adapted from mathiasbynens/punycode.js
- Demo: Resolver
- Demo: Tokenizer
Passes 100% IDNATestV2(This test is IDNA2003)- Passes 100% NormalizationTests
- Emoji Test
- Generated Report vs
eth-ens-namehash
Latest version • Prior (IDNA2003)
import {ens_normalize} from '@adraffy/ens-normalize';
// browser:
// 'https://unpkg.com/@adraffy/ens-normalize@latest/dist/ens-normalize.min.js'
// alternatives:
// - ens-normalize-xbidi.min.js (no CheckBidi)
// - ens-normalize-xnfc.min.js (use default String.normalize)
// see: /dist/ for more
// single-function one-argument API
// - ens_normalize(string): string
let normalized = ens_normalize('🚴♂️.eth'); // throws if error
// ready for namehash
// errors:
// - not a string
// - contains disallowed character
// - punycode error
// - label has double-hyphen
// - label starts/ends with hyphen
// - label starts with combining mark
// - character out of context
// - bidi error
// note: does not enforce .eth TLD 3-character minimum
Building
- Clone to access
build/
. The actual source is inbuild/lib-normalize.js
. You can run this file directly. - Run
node build/unicode.js download
to download data from unicode.org. - Run
node build/unicode.js parse
to parse those files into JSON files. - Run
node build/build-tables.js
to extract the necessary tables as JSON and generate compressed tables as binary. - Run
npm run test-source
to testbuild/lib-normalize.js
. - Run
npm run build
ornode build/build.js
to inject the compressed tables into the source template and create the normal and minifieddist/
files. - Run
npm run test-build
to testdist/ens-normalize.js
.