mirror of
https://github.com/TeamPiped/Piped.git
synced 2026-03-15 21:17:01 +00:00
Tree shake DomPurify.
This commit is contained in:
27
src/main.js
27
src/main.js
@@ -56,8 +56,6 @@ library.add(
|
||||
import router from "@/router/router.js";
|
||||
import App from "./App.vue";
|
||||
|
||||
import DOMPurify from "dompurify";
|
||||
|
||||
import TimeAgo from "javascript-time-ago";
|
||||
|
||||
import en from "javascript-time-ago/locale/en";
|
||||
@@ -120,9 +118,6 @@ const mixin = {
|
||||
return response.json();
|
||||
});
|
||||
},
|
||||
purifyHTML(original) {
|
||||
return DOMPurify.sanitize(original);
|
||||
},
|
||||
setPreference(key, value, disableAlert = false) {
|
||||
try {
|
||||
localStorage.setItem(key, value);
|
||||
@@ -195,19 +190,6 @@ const mixin = {
|
||||
timeAgo(time) {
|
||||
return timeAgo.format(time);
|
||||
},
|
||||
urlify(string) {
|
||||
if (!string) return "";
|
||||
const urlRegex = /(((https?:\/\/)|(www\.))[^\s]+)/g;
|
||||
const emailRegex = /([\w-\\.]+@(?:[\w-]+\.)+[\w-]{2,4})/g;
|
||||
return string
|
||||
.replace(urlRegex, url => {
|
||||
if (url.endsWith("</a>") || url.endsWith("<a")) return url;
|
||||
return `<a href="${url}" target="_blank">${url}</a>`;
|
||||
})
|
||||
.replace(emailRegex, email => {
|
||||
return `<a href="mailto:${email}">${email}</a>`;
|
||||
});
|
||||
},
|
||||
async updateWatched(videos) {
|
||||
if (window.db && this.getPreferenceBoolean("watchHistory", false)) {
|
||||
var tx = window.db.transaction("watch_history", "readonly");
|
||||
@@ -265,15 +247,6 @@ const mixin = {
|
||||
elem.click();
|
||||
elem.remove();
|
||||
},
|
||||
rewriteDescription(text) {
|
||||
return this.urlify(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>");
|
||||
},
|
||||
getChannelGroupsCursor() {
|
||||
if (!window.db) return;
|
||||
var tx = window.db.transaction("channel_groups", "readonly");
|
||||
|
||||
Reference in New Issue
Block a user