Fix handling of ens domains containing international characters

master
Pete Jihoon Kim 7 years ago
parent a12ca41093
commit 1749746dd8

@ -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

@ -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)
})

Loading…
Cancel
Save