23 Commits
1.0.1 ... 1.0.6

Author SHA1 Message Date
Vitaly Puzrin
7a61c5e20e 1.0.6 released 2020-05-18 08:06:29 +03:00
Vitaly Puzrin
87c8f30f3e dev deps bump 2020-05-18 08:04:21 +03:00
Vitaly Puzrin
9d6bc548cd Encode 2028 & 2029 chars in text form, close #7 2020-05-18 08:02:04 +03:00
Vitaly Puzrin
193738762a Mapping data update to v13.0.0 2020-05-18 07:30:45 +03:00
Vitaly Puzrin
af3e0a9b7c 1.0.5 released 2020-03-03 05:02:17 +03:00
Vitaly Puzrin
7ff0277276 Merge pull request #6 from turt2live/patch-1
Ship the TypeScript declarations too
2020-03-03 04:59:09 +03:00
Travis Ralston
d6ec78e7c1 Ship the TypeScript declarations too
TypeScript declarations were added, but unfortunately they didn't get put into the release because they weren't listed as a file.
2020-03-02 18:19:17 -07:00
Vitaly Puzrin
7ac80669b0 1.0.4 released 2020-02-05 22:14:43 +03:00
Vitaly Puzrin
0fca8b9920 Revert "Use HTTPS do download confusables"
This reverts commit a6c803a17d.
2020-02-05 22:06:25 +03:00
Vitaly Puzrin
b7a5926d98 Merge pull request #5 from foldleft/foldleft/type-defs
add a type definition file for typescript users
2020-02-05 21:55:09 +03:00
Zoe
fee537fbf9 add a type definition file for typescript users 2020-02-05 12:01:02 +00:00
Vitaly Puzrin
5fa3d0af6f Use HTTPS do download confusables (#4)
Use HTTPS do download confusables
2020-01-15 20:13:39 +03:00
Jonathan Leitschuh
a6c803a17d Use HTTPS do download confusables 2020-01-15 12:10:41 -05:00
Vitaly Puzrin
2f17975f88 1.0.3 released 2019-11-04 19:50:58 +03:00
Vitaly Puzrin
ef5dfe6afc Dev deps bump 2019-11-04 19:48:24 +03:00
Vitaly Puzrin
cb57f4472e Travis-CI: use last stable node for testing 2019-11-04 19:43:33 +03:00
Vitaly Puzrin
189c8c278c Merge pull request #3 from petitchevalroux/v-12.1.0
Mapping data update to v12.1.0
2019-11-04 19:10:58 +03:00
Patrick Poulain
0b428f40cf Mapping data update to v12.1.0 2019-11-04 17:03:50 +01:00
Vitaly Puzrin
fed5576b38 Improve example 2017-04-09 14:23:14 +03:00
Vitaly Puzrin
77448891d7 Typo fix 2017-03-15 07:26:18 +03:00
Vitaly Puzrin
59c5f0e151 Add more explanations to readme 2017-03-05 06:06:21 +03:00
Vitaly Puzrin
0bc3804849 1.0.2 released 2017-03-05 05:21:05 +03:00
Vitaly Puzrin
ce667c335a Mapping data update to v9.0.0 2017-03-05 05:16:50 +03:00
8 changed files with 420 additions and 112 deletions

View File

@@ -1,5 +1,3 @@
language: node_js
node_js:
- '4'
- '6'
sudo: false
- node

View File

@@ -1,3 +1,38 @@
1.0.6 / 2020-05-18
------------------
- Update mapping data to version 13.0.0
http://www.unicode.org/Public/security/latest/confusables.txt
- Encode `\u2028` & `\u2029` as text, #7.
- Dev deps bump.
1.0.5 / 2020-03-03
------------------
- Include missed TS definition into npm package.
1.0.4 / 2020-02-05
------------------
- Added TS definition.
1.0.3 / 2019-11-04
------------------
- Update mapping data to version 12.1.0
http://www.unicode.org/Public/security/latest/confusables.txt
- Dev deps bump.
1.0.2 / 2017-03-05
------------------
- Update mapping data to version 9.0.0
http://www.unicode.org/Public/security/latest/confusables.txt
1.0.1 / 2016-12-09
------------------

View File

@@ -4,8 +4,14 @@
[![NPM version](https://img.shields.io/npm/v/unhomoglyph.svg?style=flat)](https://www.npmjs.org/package/unhomoglyph)
> 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](http://www.unicode.org/Public/security/latest/confusables.txt), v8.0.0.
Data source - [Recommended confusable mapping for IDN](http://www.unicode.org/Public/security/latest/confusables.txt), 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
@@ -21,6 +27,18 @@ npm install unhomoglyph --save
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`);
}
```

448
data.json

File diff suppressed because it is too large Load Diff

4
index.d.ts vendored Normal file
View File

@@ -0,0 +1,4 @@
declare module 'unhomoglyph' {
const unhomoglyph: (s: string) => string;
export default unhomoglyph;
}

View File

@@ -1,6 +1,6 @@
{
"name": "unhomoglyph",
"version": "1.0.1",
"version": "1.0.6",
"description": "Replace all homoglyphs with base characters.",
"keywords": [
"homoglyph",
@@ -10,7 +10,8 @@
"license": "MIT",
"files": [
"index.js",
"data.json"
"data.json",
"index.d.ts"
],
"scripts": {
"lint": "eslint .",
@@ -18,7 +19,7 @@
"update": "node update.js && npm test"
},
"devDependencies": {
"eslint": "^3.11.1",
"mocha": "^3.2.0"
"eslint": "^7.0.0",
"mocha": "^7.1.2"
}
}

View File

@@ -26,4 +26,8 @@ describe('unhomoglyph', function () {
assert.strictEqual(unhomoglyph('1abcаа'), 'labcaa');
});
it('2028 & 2029 should be ok after replace in updater', function () {
assert.strictEqual(data['\u2028'], ' ');
assert.strictEqual(data['\u2029'], ' ');
});
});

View File

@@ -37,8 +37,14 @@ function save(str) {
result[src] = dst;
});
let output = JSON.stringify(result, null, ' ')
// Workaround for ES9 <=> ES10 inconsistency
// https://github.com/nodeca/unhomoglyph/issues/7
// https://github.com/facebook/hermes/issues/235#issuecomment-623606572
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029');
fs.writeFileSync(SAVE_PATH, JSON.stringify(result, null, ' '));
fs.writeFileSync(SAVE_PATH, output);
console.log('Done!');
}