mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 07:43:31 -07:00
Fix data-canonical-url and improve test specificity
- Use canonical (non-proxy) URL for data-canonical-url attribute - Extract thumbnailUrl to local variable to avoid duplicate calls - Update test to check for img with video ID in src, avoiding false positives - Test now verifies the actual thumbnail data rather than any link Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
parent
58504e2b8d
commit
08b03cf27e
|
|
@ -181,15 +181,14 @@ public class HtmlEmbedSpecs
|
|||
);
|
||||
|
||||
// Assert
|
||||
var youtubeUrl = message
|
||||
.QuerySelectorAll("a")
|
||||
.Select(e => e.GetAttribute("href"))
|
||||
// Check that the YouTube video thumbnail image exists with the correct video ID
|
||||
var youtubeThumbnailSrc = message
|
||||
.QuerySelectorAll("img")
|
||||
.Select(e => e.GetAttribute("src"))
|
||||
.WhereNotNull()
|
||||
.FirstOrDefault(s =>
|
||||
s.Contains("youtube.com/watch?v=qOWW4OlgbvE", StringComparison.Ordinal)
|
||||
);
|
||||
.FirstOrDefault(s => s.Contains("qOWW4OlgbvE", StringComparison.Ordinal));
|
||||
|
||||
youtubeUrl.Should().NotBeNull();
|
||||
youtubeThumbnailSrc.Should().NotBeNull();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
|||
|
|
@ -427,7 +427,11 @@
|
|||
@* Video thumbnail *@
|
||||
<div class="chatlog__embed-youtube-container">
|
||||
<a href="@youTubeVideoEmbed.Url">
|
||||
<img class="chatlog__embed-youtube-thumbnail" src="@await ResolveAssetUrlAsync(youTubeVideoEmbed.GetThumbnailUrl(embed))" alt="YouTube video thumbnail" loading="lazy" onerror="this.style.visibility='hidden'" data-canonical-url="@youTubeVideoEmbed.GetThumbnailUrl(embed)">
|
||||
@{
|
||||
var thumbnailUrl = youTubeVideoEmbed.GetThumbnailUrl(embed);
|
||||
var thumbnailCanonicalUrl = embed.Thumbnail?.Url ?? youTubeVideoEmbed.ThumbnailUrl;
|
||||
}
|
||||
<img class="chatlog__embed-youtube-thumbnail" src="@await ResolveAssetUrlAsync(thumbnailUrl)" alt="YouTube video thumbnail" loading="lazy" onerror="this.style.visibility='hidden'" data-canonical-url="@thumbnailCanonicalUrl">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue