Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const renderDescriptionWithLinks = text => {
return replace(text, MARKDOWN_LINK, (fullLink, text, url) => (
<a rel="noopener noreferrer" href="{url}">
{text}
</a>
));
};
let textWithoutAsciiAliases = textWithAsciiAliases;
while (previousTextWithoutAsciiAliases !== textWithoutAsciiAliases) {
previousTextWithoutAsciiAliases = textWithoutAsciiAliases;
textWithoutAsciiAliases = textWithoutAsciiAliases.replace(
asciiAliasesRegex,
replaceAsciiAliases
);
}
return textWithoutAsciiAliases;
}
const textWithouAsciiAliases = replaceAllAsciiAliases(text);
return replace(
textWithouAsciiAliases.replace(aliasesRegex, replaceAliases),
unicodeEmojiRegex,
replaceUnicodeEmoji
);
}
export const renderMarkdownLinks = (text: string) => {
const MARKDOWN_LINK = /(?:\[(.*?)\]\((.*?)\))/g;
return replace(text, MARKDOWN_LINK, (fullLink, text, url) => (
<a rel="noopener noreferrer" href="{url}">
{text}
</a>
));
};
export const renderLinks = text => {
return replace(text, URL, (fullLink, text, url) => (
<a rel="noopener nofollower" href="{url}">
{text}
</a>
));
};
text,
...rest
}: Props) {
let regex;
if (highlight instanceof RegExp) {
regex = highlight;
} else {
regex = new RegExp(
(highlight || '').replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&'),
caseSensitive ? 'g' : 'gi'
);
}
return (
<span>
{highlight
? replace(text, regex, (tag, index) => (
<mark>{processResult ? processResult(tag) : tag}</mark>
))
: text}
</span>
);
}
export function formatCourseDescription(raw, nameFormatter) {
return raw ? replace(raw, COURSE_REGEX, nameFormatter) : '';
}
export default (text: string) => {
return replace(text, MARKDOWN_LINK, (fullLink, text, url) => {
const regexp = new RegExp(SPECTRUM_URLS, 'ig');
const match = regexp.exec(url);
if (match && match[0] && match[1]) return {text};
return (
<a rel="noopener noreferrer" href="{url}">
{text}
</a>
);
});
};