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;
}
}
});
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));
export function transformLinksInHtml(html: string): string {
let content = linkifyHtml(html);
content = addIframeForStoryChief(content);
return content;
}
const parsedMessage = Array.from(message)
const emotes = this.parseAdditionalEmotes(words, userstate.emotes || {})
this.parseEmotes(parsedMessage, emotes)
this.parseHighlights(words, parsedMessage)
this.parseMentions(words, parsedMessage, currentUsername)
this.parsePreviews(message)
let parsedMessageStr = escape(parsedMessage).join('')
if (!_.isNil(userstate.bits) && userstate.bits > 0) {
parsedMessageStr = this.parseCheermotes(parsedMessageStr, userstate.bits)
}
return linkifyHtml(parsedMessageStr, {
attributes: {
'data-tip': '',
},
})
}
linkify: function (content) {
return LinkifyHtml(content);
},
},
export default (activity) => {
const linkifyOptions = {
ignoreTags: ['code', 'pre'],
className: 'ciscospark-activity-link'
};
if (activity.content) {
return Object.assign({}, activity, {content: linkifyHtml(activity.content, linkifyOptions)});
}
return Object.assign({}, activity, {content: linkifyStr(activity.displayName, linkifyOptions)});
};
export const linkify: IntermediateModerationPhase = async ({
comment,
}): Promise => ({
body: linkifyjs(comment.body, config),
});