Linkify URLs containing @
This commit is contained in:
parent
d387481001
commit
980862768b
3 changed files with 26 additions and 6 deletions
|
@ -133,6 +133,15 @@ function findLinks(text, caretLocation) {
|
|||
);
|
||||
}
|
||||
|
||||
function hasAuth(url) {
|
||||
try {
|
||||
const urlObject = new URL(url);
|
||||
return Boolean(urlObject.username);
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function getDomain(url) {
|
||||
try {
|
||||
const urlObject = new URL(url);
|
||||
|
@ -215,6 +224,11 @@ function assembleChunks(chunkDescriptors) {
|
|||
const ASCII_PATTERN = new RegExp('[\\u0000-\\u007F]', 'g');
|
||||
|
||||
function isLinkSneaky(link) {
|
||||
// Any links which contain auth are considered sneaky
|
||||
if (hasAuth(link)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const domain = getDomain(link);
|
||||
// If the domain is falsy, something fishy is going on
|
||||
if (!domain) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue