Merge pull request #5 from ensdomains/mdt/ascii-to-unicode

normalize toUnicode, version bump
master^2
Muhammed Tanrıkulu 3 years ago committed by GitHub
commit f62f351f8c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -23,7 +23,7 @@ function namehash (inputName) {
} }
function normalize(name) { function normalize(name) {
return name ? uts46.toAscii(name, {useStd3ASCII: true, transitional: false}) : name return name ? uts46.toUnicode(name, {useStd3ASCII: true, transitional: false}) : name
} }
module.exports = { module.exports = {

@ -1,6 +1,6 @@
{ {
"name": "@ensdomains/eth-ens-namehash", "name": "@ensdomains/eth-ens-namehash",
"version": "2.0.14", "version": "2.0.15",
"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": {

@ -47,7 +47,15 @@ test('normalize ascii domain', (t) => {
test('normalize international domain', (t) => { test('normalize international domain', (t) => {
t.plan(1) t.plan(1)
const input = 'fоо.eth' // with cyrillic 'o' const input = 'fоо.eth' // with cyrillic 'o'
const expected = 'xn--f-1tba.eth' const expected = 'fоо.eth'
const output = namehash.normalize(input)
t.equal(output, expected)
})
test('normalize capitalized domain', (t) => {
t.plan(1)
const input = 'Foo.eth' // latin chars only
const expected = 'foo.eth'
const output = namehash.normalize(input) const output = namehash.normalize(input)
t.equal(output, expected) t.equal(output, expected)
}) })
@ -55,7 +63,7 @@ test('normalize international domain', (t) => {
test('normalize emoji domain', (t) => { test('normalize emoji domain', (t) => {
t.plan(1) t.plan(1)
const input = '🦚.eth' const input = '🦚.eth'
const expected = 'xn--qt9h.eth' const expected = '🦚.eth'
const output = namehash.normalize(input) const output = namehash.normalize(input)
t.equal(output, expected) t.equal(output, expected)
}) })

Loading…
Cancel
Save