JSPM

  • Created
  • Published
  • Downloads 1654360
  • Score
    100M100P100Q225393F
  • 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.

Demo

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

// example:
let normalized = ens_normalize('🚴‍♂️.eth'); // throws if error
// this value is ready for hashing

// optional argument: ignore_disallowed (default: false)
// when truthy, disallowed characters are ignored 
ens_normalize('_')       // throws: disallowed
ens_normalize('_', true) // === ''

// errors:
// - not a string
// - contains disallowed character if !ignore_disallowed
// - puny decode failure
// - 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

Build Notes

  • Clone the repo to access test/. These files are not included in the npm version.
  • The actual source is in test/ens-normalize.src.js. Use npm run render after modification to build a new ens-normalize.js.
  • Use npm run dist to build the minified version.