Improve handling for URLs composed of mixed character sets
This commit is contained in:
parent
e4b0901620
commit
ae2db9f09a
6 changed files with 185 additions and 1 deletions
|
@ -5,6 +5,7 @@ const {
|
|||
getTitleMetaTag,
|
||||
getImageMetaTag,
|
||||
isLinkInWhitelist,
|
||||
isLinkSneaky,
|
||||
isMediaLinkInWhitelist,
|
||||
} = require('../../js/modules/link_previews');
|
||||
|
||||
|
@ -305,4 +306,30 @@ describe('Link previews', () => {
|
|||
assert.deepEqual(expected, actual);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#isLinkSneaky', () => {
|
||||
it('returns false for all-latin domain', () => {
|
||||
const link = 'https://www.amazon.com';
|
||||
const actual = isLinkSneaky(link);
|
||||
assert.strictEqual(actual, false);
|
||||
});
|
||||
|
||||
it('returns true for Latin + Cyrillic domain', () => {
|
||||
const link = 'https://www.aмazon.com';
|
||||
const actual = isLinkSneaky(link);
|
||||
assert.strictEqual(actual, true);
|
||||
});
|
||||
|
||||
it('returns true for Latin + Greek domain', () => {
|
||||
const link = 'https://www.αpple.com';
|
||||
const actual = isLinkSneaky(link);
|
||||
assert.strictEqual(actual, true);
|
||||
});
|
||||
|
||||
it('returns true for Latin + High Greek domain', () => {
|
||||
const link = `https://www.apple${String.fromCodePoint(0x101a0)}.com`;
|
||||
const actual = isLinkSneaky(link);
|
||||
assert.strictEqual(actual, true);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue