Merge pull request #11 from petejkim/master

Fix handling of ens domains containing international characters
master
Dan Finlay 7 years ago committed by GitHub
commit edb761a71c
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.toUnicode(name, {useStd3ASCII: true, transitional: false}) : name return name ? uts46.toAscii(name, {useStd3ASCII: true, transitional: false}) : name
} }
exports.hash = namehash exports.hash = namehash

@ -35,10 +35,20 @@ test('foo.eth', (t) => {
t.equal(output, expected) t.equal(output, expected)
}) })
test('normalize', (t) => { test('normalize ascii domain', (t) => {
t.plan(1) t.plan(1)
const input = 'foo.eth' const input = 'foo.eth' // latin chars only
const expected = 'foo.eth' const expected = 'foo.eth'
const output = namehash.normalize(input) const output = namehash.normalize(input)
t.equal(output, expected) 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)
})

Loading…
Cancel
Save