mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 15:53:30 -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
|
// Assert
|
||||||
var youtubeUrl = message
|
// Check that the YouTube video thumbnail image exists with the correct video ID
|
||||||
.QuerySelectorAll("a")
|
var youtubeThumbnailSrc = message
|
||||||
.Select(e => e.GetAttribute("href"))
|
.QuerySelectorAll("img")
|
||||||
|
.Select(e => e.GetAttribute("src"))
|
||||||
.WhereNotNull()
|
.WhereNotNull()
|
||||||
.FirstOrDefault(s =>
|
.FirstOrDefault(s => s.Contains("qOWW4OlgbvE", StringComparison.Ordinal));
|
||||||
s.Contains("youtube.com/watch?v=qOWW4OlgbvE", StringComparison.Ordinal)
|
|
||||||
);
|
|
||||||
|
|
||||||
youtubeUrl.Should().NotBeNull();
|
youtubeThumbnailSrc.Should().NotBeNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
|
|
|
||||||
|
|
@ -427,7 +427,11 @@
|
||||||
@* Video thumbnail *@
|
@* Video thumbnail *@
|
||||||
<div class="chatlog__embed-youtube-container">
|
<div class="chatlog__embed-youtube-container">
|
||||||
<a href="@youTubeVideoEmbed.Url">
|
<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>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue