Skip to content

Commit

Permalink
Merge pull request Arachnid#11 from petejkim/master
Browse files Browse the repository at this point in the history
Fix handling of ens domains containing international characters
  • Loading branch information
danfinlay authored Dec 14, 2017
2 parents a12ca41 + 1749746 commit edb761a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function namehash (inputName) {
}

function normalize(name) {
return name ? uts46.toUnicode(name, {useStd3ASCII: true, transitional: false}) : name
return name ? uts46.toAscii(name, {useStd3ASCII: true, transitional: false}) : name
}

exports.hash = namehash
Expand Down
14 changes: 12 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,20 @@ test('foo.eth', (t) => {
t.equal(output, expected)
})

test('normalize', (t) => {
test('normalize ascii domain', (t) => {
t.plan(1)
const input = 'foo.eth'
const input = 'foo.eth' // latin chars only
const expected = 'foo.eth'
const output = namehash.normalize(input)
t.equal(output, expected)
})


test('normalize international domain', (t) => {
t.plan(1)
const input = 'fоо.eth' // with cyrillic 'o'
const expected = 'xn--f-1tba.eth'
const output = namehash.normalize(input)
t.equal(output, expected)
})

0 comments on commit edb761a

Please sign in to comment.