Skip to content

Replace all homoglyphs with base characters. Useful to detect similar strings.

License

Notifications You must be signed in to change notification settings

nodeca/unhomoglyph

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Vitaly Puzrin
May 18, 2020
7a61c5e · May 18, 2020

History

27 Commits
Dec 9, 2016
Dec 9, 2016
Dec 9, 2016
Nov 4, 2019
May 18, 2020
Dec 9, 2016
May 18, 2020
May 18, 2020
Feb 5, 2020
Dec 9, 2016
May 18, 2020
May 18, 2020
May 18, 2020

Repository files navigation

unhomoglyph

Build Status NPM version

Replace all homoglyphs with base characters. Useful to detect similar strings. For example, to prohibit register similar looking nicknames at websites.

Data source - Recommended confusable mapping for IDN, v13.0.0.

Note! Text after transform is NOT intended be read by humans. For example, m will be transformed to r + n. Goal is to compare 2 strings after transform, to check if sources looks similar or not. If sources look similar, then transformed strings are equal.

Install

npm install unhomoglyph --save

Example

const unhomoglyph = require('unhomoglyph');

console.log(unhomoglyph('AΑАᎪᗅᴀꓮ')); // => AAAAAAA
console.log(unhomoglyph('m'));        // => rn (r + n)

//
// Compare nicknames
//

const username1 = 'm';
const username2 = 'rn';

if (unhomoglyph(username1) === unhomoglyph(username2)) {
  console.log(`"${username1}" and "${username2} look similar`);
}

Update

npm run update

License

MIT