mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	Merge pull request #2046 from Bnyro/description-links
Properly rewrite channel descriptions
This commit is contained in:
		
						commit
						9a6a53535f
					
				
					 3 changed files with 11 additions and 8 deletions
				
			
		| 
						 | 
				
			
			@ -10,7 +10,7 @@
 | 
			
		|||
        <img v-if="channel.bannerUrl" :src="channel.bannerUrl" class="w-full pb-1.5" loading="lazy" />
 | 
			
		||||
        <!-- eslint-disable-next-line vue/no-v-html -->
 | 
			
		||||
        <p class="whitespace-pre-wrap">
 | 
			
		||||
            <span v-html="purifyHTML(urlify(channel.description))" />
 | 
			
		||||
            <span v-html="purifyHTML(rewriteDescription(channel.description))" />
 | 
			
		||||
        </p>
 | 
			
		||||
 | 
			
		||||
        <button
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -408,13 +408,7 @@ export default {
 | 
			
		|||
                                elem.outerHTML = elem.getAttribute("href");
 | 
			
		||||
                        });
 | 
			
		||||
                        xmlDoc.querySelectorAll("br").forEach(elem => (elem.outerHTML = "\n"));
 | 
			
		||||
                        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\.)?youtu\.be\/(?:watch\?v=)?([/a-zA-Z0-9_?=&-]*)/gm,
 | 
			
		||||
                                "/watch?v=$1",
 | 
			
		||||
                            )
 | 
			
		||||
                            .replaceAll("\n", "<br>");
 | 
			
		||||
                        this.video.description = this.rewriteDescription(xmlDoc.querySelector("body").innerHTML);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
        },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -251,6 +251,15 @@ 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>");
 | 
			
		||||
        },
 | 
			
		||||
    },
 | 
			
		||||
    computed: {
 | 
			
		||||
        authenticated(_this) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue