JSPM

  • Created
  • Published
  • Downloads 1654360
  • Score
    100M100P100Q225569F
  • License MIT

Compact ES6 Ethereum Name Service (ENS) Name Normalizer

Package Exports

  • @adraffy/ens-normalize
  • @adraffy/ens-normalize/ens-normalize.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, 0-dependancy Compact ES6 Ethereum Name Service (ENS) Name Normalizer.

This library is 5-10x smaller than existing implementations.

Reference: UTS-46 v14.0.0

Demo | Emoji Test

import {ens_normalize} from '@adraffy/ens-normalize';
// browser:
// import {ens_normalize} from 'https://unpkg.com/@adraffy/ens-normalize@latest/ens-normalize.js';

// simple api:
let normalized = ens_normalize('🚴‍♂️.eth'); // throws if error

// errors:
// - contains disallowed character
// - puny decode failure
// - label not idna after puny decode
// - label has double-hyphen at [3:4]
// - label starts/ends with hyphen
// - label starts with combining mark

// note: does not enforce .eth TLD 3-byte minimum

Adapted Puny Decode from mathiasbynens/punycode.js.