mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2025-12-26 13:20:48 +00:00
Linkify URLs containing @
This commit is contained in:
committed by
Scott Nonnenberg
parent
d387481001
commit
980862768b
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user