Don't linkify invalid URLs
This commit is contained in:
parent
9fc127f063
commit
f0028a5cfe
2 changed files with 30 additions and 2 deletions
|
@ -216,9 +216,17 @@ const ASCII_PATTERN = new RegExp('[\\u0000-\\u007F]', 'g');
|
|||
|
||||
function isLinkSneaky(link) {
|
||||
const domain = getDomain(link);
|
||||
// If the domain is falsy, something fishy is going on
|
||||
if (!domain) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is necesary because getDomain returns domains in punycode form. We check whether
|
||||
// it's available for the StyleGuide.
|
||||
// Domains cannot contain encoded characters
|
||||
if (domain.includes('%')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// This is necesary because getDomain returns domains in punycode form.
|
||||
const unicodeDomain = nodeUrl.domainToUnicode
|
||||
? nodeUrl.domainToUnicode(domain)
|
||||
: domain;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue