File tree Expand file tree Collapse file tree 3 files changed +19
-2
lines changed
LinkDotNet.Blog.IntegrationTests/Web/Pages Expand file tree Collapse file tree 3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1
- using System . Threading . Tasks ;
1
+ using System ;
2
+ using System . Threading . Tasks ;
2
3
using Bunit ;
3
4
using FluentAssertions ;
4
5
using LinkDotNet . Blog . TestUtilities ;
@@ -26,6 +27,19 @@ public async Task ShouldOnlyDisplayTagsGivenByParameter()
26
27
tags . Should ( ) . HaveCount ( 2 ) ;
27
28
}
28
29
30
+ [ Fact ]
31
+ public async Task ShouldHandleSpecialCharacters ( )
32
+ {
33
+ using var ctx = new TestContext ( ) ;
34
+ await AddBlogPostWithTagAsync ( "C#" ) ;
35
+ ctx . Services . AddScoped < IRepository > ( _ => BlogPostRepository ) ;
36
+ var cut = ctx . RenderComponent < SearchByTag > ( p => p . Add ( s => s . Tag , Uri . EscapeDataString ( "C#" ) ) ) ;
37
+
38
+ var tags = cut . FindAll ( ".blog-card" ) ;
39
+
40
+ tags . Should ( ) . HaveCount ( 1 ) ;
41
+ }
42
+
29
43
private async Task AddBlogPostWithTagAsync ( string tag )
30
44
{
31
45
var blogPost = new BlogPostBuilder ( ) . WithTags ( tag ) . Build ( ) ;
Original file line number Diff line number Diff line change 17
17
IList <BlogPost > _blogPosts = new List <BlogPost >();
18
18
protected override async Task OnInitializedAsync ()
19
19
{
20
+ Tag = Uri .UnescapeDataString (Tag );
20
21
_blogPosts = (await _repository .GetAllAsync (b => b .Tags .Any (t => t .Content == Tag ), b => b .UpdatedDate )).ToList ();
21
22
}
22
23
}
Original file line number Diff line number Diff line change 1
1
@using LinkDotNet .Domain
2
+ @using System .Net
3
+ @using System .Web
2
4
@inject NavigationManager _navigationManager
3
5
@inherits MarkdownComponentBase
4
6
<div class =" blog-card @AltCssClass" >
12
14
<ul >
13
15
@foreach ( var tag in BlogPost .Tags .Select (t => t .Content ))
14
16
{
15
- <li ><a href =" /searchByTag/@tag" >@tag </a ></li >
17
+ <li ><a href =" /searchByTag/@(Uri.EscapeDataString( tag)) " >@tag </a ></li >
16
18
}
17
19
</ul >
18
20
</li >
You can’t perform that action at this time.
0 commit comments