Don't replace timestamp's text in description.

This commit is contained in:
Kavin 2022-09-01 20:50:06 +05:30
parent b5e80b86a9
commit a6927f9bd9
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
2 changed files with 5 additions and 1 deletions

View file

@ -380,7 +380,10 @@ export default {
const parser = new DOMParser(); const parser = new DOMParser();
const xmlDoc = parser.parseFromString(this.video.description, "text/html"); const xmlDoc = parser.parseFromString(this.video.description, "text/html");
xmlDoc.querySelectorAll("a").forEach(elem => (elem.outerHTML = elem.getAttribute("href"))); xmlDoc.querySelectorAll("a").forEach(elem => {
if (!elem.innerText.match(/(?:[\d]{1,2}:)?(?:[\d]{1,2}):(?:[\d]{1,2})/))
elem.outerHTML = elem.getAttribute("href");
});
xmlDoc.querySelectorAll("br").forEach(elem => (elem.outerHTML = "\n")); xmlDoc.querySelectorAll("br").forEach(elem => (elem.outerHTML = "\n"));
this.video.description = this.urlify(xmlDoc.querySelector("body").innerHTML) this.video.description = this.urlify(xmlDoc.querySelector("body").innerHTML)
.replaceAll(/(?:http(?:s)?:\/\/)?(?:www\.)?youtube\.com(\/[/a-zA-Z0-9_?=&-]*)/gm, "$1") .replaceAll(/(?:http(?:s)?:\/\/)?(?:www\.)?youtube\.com(\/[/a-zA-Z0-9_?=&-]*)/gm, "$1")

View file

@ -177,6 +177,7 @@ const mixin = {
const emailRegex = /([\w-\\.]+@(?:[\w-]+\.)+[\w-]{2,4})/g; const emailRegex = /([\w-\\.]+@(?:[\w-]+\.)+[\w-]{2,4})/g;
return string return string
.replace(urlRegex, url => { .replace(urlRegex, url => {
if (url.endsWith("</a>")) return url;
return `<a href="${url}" target="_blank">${url}</a>`; return `<a href="${url}" target="_blank">${url}</a>`;
}) })
.replace(emailRegex, email => { .replace(emailRegex, email => {