Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tagName: "span"
});
linkifyHtml("#swag", {
tagName: {
hashtag: "span"
}
});
/* target */
linkifyHtml("github.com", {
target: "_parent"
});
linkifyHtml("test-email@example.com", {
target: {
url: "_parent",
email: null
}
});
/* validate */
// Don't linkify links that don't begin in a protocol
// e.g., "http://google.com" will be linkified, but "google.com" will not.
linkifyHtml("www.google.com", {
validate: {
url(value) {
return /^(http|ftp)s?:\/\//.test(value);
}
}
linkifyHtml("", {
events: {
click(e) {
alert("Link clicked!");
},
mouseover(e) {
alert("Link hovered!");
}
}
});
/* defaultProtocol */
/* format */
linkifyHtml("", {
format(value, type) {
if (type === "url" && value.length > 50) {
value = value.slice(0, 50) + "…";
}
return value;
}
});
linkifyHtml("", {
format: {
url(value) {
return value.length > 50 ? value.slice(0, 50) + "…" : value;
}
}
});
const handleNewModel = async (db, attrs) => {
// console.log('emitter', attrs);
if (attrs.radiksType !== 'Message') {
return true;
}
const { content, createdBy } = attrs;
console.log(`@${createdBy}: ${content}`);
const matches = linkify.find(content);
const mentions = {};
matches.forEach((match) => {
if (match.type === 'mention') {
const username = match.value.slice(1);
mentions[username] = true;
}
});
const mentionedUsers = Object.keys(mentions);
console.log('Mentions:', mentionedUsers.join(','));
const centralCollection = db.collection(CENTRAL_COLLECTION);
const collectMentionsToSend = mentionedUsers.map((username) => new Promise(async (resolve, reject) => {
try {
_processHyperlinks: _.throttle(function() {
var that = this,
messageText = this.ui.messageBody.val()||'',
links = linkify.find(messageText),
missingLinks = [],
goneModels = [];
//console.log("_processHyperlinks called");
//console.log(links);
//console.log(this.attachmentsCollection);
// this.attachmentsCollection.comparator = function (attachmentModel) {
// var index = _.findIndex(links, function(link) {
// //console.log(attachmentModel.getDocument().get('uri'), link.href);
// return attachmentModel.getDocument().get('uri') === link.href;
// })
// //console.log("attachmentsCollection comparator returning: ", index);
// return index;
// };
goneModels = that.attachmentsCollection.filter(function(attachment) {
var document = attachment.getDocument();
passToNextState(msgTimes, msgContent){
let links = [];
if(msgTimes) {
console.log("messagestimes", msgTimes.length);
this.setState({messagesTimes: msgTimes});
}
if(msgContent) {
console.log("messagesContent", msgContent.length);
links = linkify.find(msgContent).filter((d)=>{return d.type === "url"; });
this.setState({messagesContent: links});
}
// only for DEV
// this.saveToLocalStorage(msgTimes, links);
this.setState({dataReady: true});
}
function clean(dirty) {
if (!dirty) {
return dirty
}
// Convert embeds to a-tags
dirty = embedToAnchor(dirty)
dirty = linkifyHtml(dirty)
dirty = sanitizeHtml(dirty, {
allowedTags: [
'iframe',
'img',
'p',
'h3',
'h4',
'br',
'hr',
'b',
'i',
'em',
'strong',
'a',
'pre',
'ul',
export const add = (data: ChatMessage, fast: boolean) => {
let chat;
if (data.room === 'lobby') {
chat = $('#lobby-chat-text');
} else if ($('#lobby-chat-pregame-text').is(':visible')) {
chat = $('#lobby-chat-pregame-text');
} else {
chat = $('#game-chat-text');
}
if (!chat) {
throw new Error('Failed to get the chat element in the "chat.add()" function.');
}
// Linkify any links
data.msg = linkifyHtml(data.msg, {
target: '_blank',
});
// Convert emotes to images
data.msg = fillDiscordEmotes(data.msg);
data.msg = fillLocalEmotes(data.msg);
// Get the hours and minutes from the time
const datetime = new Intl.DateTimeFormat(
undefined,
{
hour: '2-digit',
minute: '2-digit',
hour12: false,
},
).format(new Date(data.datetime));
module.exports = (
ctx,
comment,
{
asset: {
settings: { premodLinksEnable },
},
}
) => {
if (premodLinksEnable) {
const links = linkify.find(comment.body.replace(/\xAD/g, ''));
if (!links || links.length === 0) {
return;
}
// Add the flag related to Trust to the comment.
return {
status: 'SYSTEM_WITHHELD',
actions: [
{
action_type: 'FLAG',
user_id: null,
group_id: 'LINKS',
metadata: {
links: comment.body,
},
},
describe("linkifyjs/string", () => {
/**
* The following tests were based on the documentation:
* https://soapbox.github.io/linkifyjs/docs/linkify-string.html
*/
const options: LinkifyOptions = {};
const str = '<p>For help with GitHub.com, please email support@github.com</p>';
const result1: string = linkifyStr(str, options);
const result2: string = linkifyStr(str);
});
describe("linkifyjs/string", () => {
/**
* The following tests were based on the documentation:
* https://soapbox.github.io/linkifyjs/docs/linkify-string.html
*/
const options: LinkifyOptions = {};
const str = '<p>For help with GitHub.com, please email support@github.com</p>';
const result1: string = linkifyStr(str, options);
const result2: string = linkifyStr(str);
});