diff --git a/.claude/settings.local.json b/.claude/settings.local.json new file mode 100644 index 00000000..296e5921 --- /dev/null +++ b/.claude/settings.local.json @@ -0,0 +1,7 @@ +{ + "permissions": { + "allow": [ + "Bash(dotnet test:*)" + ] + } +} diff --git a/src/PopForums.Test/Services/TextParsingServiceCleanForumCodeTests.cs b/src/PopForums.Test/Services/TextParsingServiceCleanForumCodeTests.cs index e521a370..80ed5ec8 100644 --- a/src/PopForums.Test/Services/TextParsingServiceCleanForumCodeTests.cs +++ b/src/PopForums.Test/Services/TextParsingServiceCleanForumCodeTests.cs @@ -272,6 +272,15 @@ public void YouTubeDoesntEmbedWhenUrlIsForChannel() Assert.Equal("blah [url=https://www.youtube.com/@sillynonsense]https://www.youtube.com/@sillynonsense[/url] blah", result); } + [Fact] + public void YouTubeDoesntEmbedWhenUrlIsForPost() + { + var service = GetService(); + _settings.AllowImages = true; + var result = service.CleanForumCode("blah https://www.youtube.com/post/Ugkx-hR1fdEJqSWSGTwzpoU4GcT_4ktnY_Qy blah"); + Assert.Equal("blah [url=https://www.youtube.com/post/Ugkx-hR1fdEJqSWSGTwzpoU4GcT_4ktnY_Qy]https://www.youtube.com/pos...T_4ktnY_Qy[/url] blah", result); + } + [Fact] public void YouTubeLinkParsedToLinkWithImagesOff() { diff --git a/src/PopForums.Test/Services/TextParsingServiceForumCodeToHtmlTests.cs b/src/PopForums.Test/Services/TextParsingServiceForumCodeToHtmlTests.cs index 33913f5b..026f013f 100644 --- a/src/PopForums.Test/Services/TextParsingServiceForumCodeToHtmlTests.cs +++ b/src/PopForums.Test/Services/TextParsingServiceForumCodeToHtmlTests.cs @@ -389,6 +389,17 @@ public void YouTubeTagHttpsConvertedToIframe() Assert.Equal("
test test test
", result); } + [Fact] + public void YouTubePostUrlParsedAsRegularLink() + { + var service = GetService(); + _settings.YouTubeHeight = 123; + _settings.YouTubeWidth = 456; + _settings.AllowImages = true; + var result = service.ForumCodeToHtml("test https://www.youtube.com/post/Ugkx-hR1fdEJqSWSGTwzpoU4GcT_4ktnY_Qy text"); + Assert.Equal("test https://www.youtube.com/pos...T_4ktnY_Qy text
", result); + } + [Fact] public void UrlWithBangParsesCorrectly() { diff --git a/src/PopForums/Services/TextParsingService.cs b/src/PopForums/Services/TextParsingService.cs index 7ea3d2e4..e84a39ff 100644 --- a/src/PopForums/Services/TextParsingService.cs +++ b/src/PopForums/Services/TextParsingService.cs @@ -68,7 +68,7 @@ public TextParsingService(ISettingsManager settingsManager) private static readonly Regex ProtocolPattern = new Regex(@"(?=/\w])(((news|(ht|f)tp(s?))\://)[\w\-\*]+(\.[\w\-/~\*]+)*/?)([\w\?=&/;\+%\*\:~,\.\-\$\|@#\(\)])*", RegexOptions.Compiled | RegexOptions.IgnoreCase); private static readonly Regex WwwPattern = new Regex(@"(?=])(((http(s?))\://)[w*\.]*(youtu\.be|youtube\.com+))(?!.*/shorts/)(?!/@)([\w\?=&/;\+%\*\:~,\.\-\$\|@#\(\)])*", RegexOptions.Compiled | RegexOptions.IgnoreCase); + private static readonly Regex YouTubePattern = new Regex(@"(?=])(((http(s?))\://)[w*\.]*(youtu\.be|youtube\.com+))(?!.*/shorts/)(?!.*/post/)(?!/@)([\w\?=&/;\+%\*\:~,\.\-\$\|@#\(\)])*", RegexOptions.Compiled | RegexOptions.IgnoreCase); ///