fix bundle issue, support both node and browser (#4)

* fix bundle issue, support both node and browser

* version bump

* update version as fix
master^2
Muhammed Tanrıkulu 3 years ago committed by GitHub
parent 7d8ab5df15
commit a84e8615f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -3,4 +3,5 @@ test/
.gitignore .gitignore
circle.yml circle.yml
index.js index.js
rollup.config.js
yarn.lock yarn.lock

@ -8,7 +8,7 @@ function namehash (inputName) {
node += '00' node += '00'
} }
name = normalize(inputName) var name = normalize(inputName)
if (name) { if (name) {
var labels = name.split('.') var labels = name.split('.')
@ -26,5 +26,7 @@ function normalize(name) {
return name ? uts46.toAscii(name, {useStd3ASCII: true, transitional: false}) : name return name ? uts46.toAscii(name, {useStd3ASCII: true, transitional: false}) : name
} }
exports.hash = namehash module.exports = {
exports.normalize = normalize hash: namehash,
normalize
}

@ -1,10 +1,10 @@
{ {
"name": "@ensdomains/eth-ens-namehash", "name": "@ensdomains/eth-ens-namehash",
"version": "2.0.13", "version": "2.0.14",
"description": "A simple module for generating ENS namehashes per spec https://github.com/ethereum/EIPs/issues/137", "description": "A simple module for generating ENS namehashes per spec https://github.com/ethereum/EIPs/issues/137",
"main": "dist/index.js", "main": "dist/index.js",
"scripts": { "scripts": {
"bundle": "browserify index.js -o dist/index.js && cp node_modules/idna-uts46-hx/idna-map.js dist/", "bundle": "rollup --config rollup.config.js",
"test": "node test" "test": "node test"
}, },
"repository": { "repository": {
@ -22,14 +22,12 @@
}, },
"homepage": "https://github.com/ensdomains/eth-ens-namehash#readme", "homepage": "https://github.com/ensdomains/eth-ens-namehash#readme",
"devDependencies": { "devDependencies": {
"tape": "^4.6.3", "@rollup/plugin-commonjs": "^20.0.0",
"babel-preset-es2015": "^6.24.1", "@rollup/plugin-node-resolve": "^13.0.5",
"babel-preset-stage-0": "^6.24.1",
"browserify": "^14.0.0"
},
"dependencies": {
"idna-uts46-hx": "^3.4.0", "idna-uts46-hx": "^3.4.0",
"js-sha3": "^0.5.7" "js-sha3": "^0.5.7",
"rollup": "^2.57.0",
"tape": "^4.6.3"
}, },
"directories": { "directories": {
"test": "test" "test": "test"

@ -0,0 +1,12 @@
import commonjs from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
export default {
input: 'index.js',
output: {
dir: 'dist',
format: 'umd',
name: 'namehash'
},
plugins: [commonjs(), nodeResolve({ browser: true })]
};

@ -1,5 +1,5 @@
const test = require('tape') const test = require('tape')
const namehash = require('../') const namehash = require('../dist')
// Test results specified in original ENS Proposal: // Test results specified in original ENS Proposal:
// https://github.com/ethereum/EIPs/issues/137 // https://github.com/ethereum/EIPs/issues/137
@ -52,3 +52,10 @@ test('normalize international domain', (t) => {
t.equal(output, expected) t.equal(output, expected)
}) })
test('normalize emoji domain', (t) => {
t.plan(1)
const input = '🦚.eth'
const expected = 'xn--qt9h.eth'
const output = namehash.normalize(input)
t.equal(output, expected)
})

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save