mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
70277fe077
Closes #2770 Closes #2634
14 lines
477 B
JavaScript
14 lines
477 B
JavaScript
import DOMPurify from "dompurify";
|
|
|
|
export const purifyHTML = html => {
|
|
return DOMPurify.sanitize(html);
|
|
};
|
|
|
|
import linkifyHtml from "linkify-html";
|
|
|
|
export const rewriteDescription = text => {
|
|
return linkifyHtml(text)
|
|
.replaceAll(/(?:http(?:s)?:\/\/)?(?:www\.)?youtube\.com(\/[/a-zA-Z0-9_?=&-]*)/gm, "$1")
|
|
.replaceAll(/(?:http(?:s)?:\/\/)?(?:www\.)?youtu\.be\/(?:watch\?v=)?([/a-zA-Z0-9_?=&-]*)/gm, "/watch?v=$1")
|
|
.replaceAll("\n", "<br>");
|
|
};
|