@@ -40,7 +40,7 @@ public void TryParse_ReturnsCorrectResult(string input, bool expectedResult, str
40
40
[ InlineData ( "http://bing.com/" , "<a target=\" _blank\" href=\" http://bing.com/\" >http://bing.com/</a>" ) ]
41
41
[ InlineData ( "http://bing.com/dir" , "<a target=\" _blank\" href=\" http://bing.com/dir\" >http://bing.com/dir</a>" ) ]
42
42
[ InlineData ( "http://bing.com/index.aspx" , "<a target=\" _blank\" href=\" http://bing.com/index.aspx\" >http://bing.com/index.aspx</a>" ) ]
43
- [ InlineData ( "http://bing " , "<a target=\" _blank\" href=\" http://bing \" >http://bing </a>" ) ]
43
+ [ InlineData ( "http://localhost " , "<a target=\" _blank\" href=\" http://localhost \" >http://localhost </a>" ) ]
44
44
public void TryParse_SupportedUrlFormats ( string input , string ? expectedOutput )
45
45
{
46
46
var result = UrlParser . TryParse ( input , WebUtility . HtmlEncode , out var modifiedText ) ;
@@ -71,6 +71,15 @@ public void TryParse_ExcludeInvalidTrailingChars(string input, string? expectedO
71
71
Assert . Equal ( expectedOutput , modifiedText ) ;
72
72
}
73
73
74
+ [ Fact ]
75
+ public void TryParse_QueryString ( )
76
+ {
77
+ var result = UrlParser . TryParse ( "https://www.example.com?query=string¶m=value" , WebUtility . HtmlEncode , out var modifiedText ) ;
78
+ Assert . True ( result ) ;
79
+
80
+ Assert . Equal ( "<a target=\" _blank\" href=\" https://www.example.com?query=string¶m=value\" >https://www.example.com?query=string&param=value</a>" , modifiedText ) ;
81
+ }
82
+
74
83
[ Theory ]
75
84
[ InlineData ( "http://www.localhost:8080" ) ]
76
85
[ InlineData ( "HTTP://WWW.LOCALHOST:8080" ) ]
@@ -83,4 +92,17 @@ public void GenerateUrlRegEx_MatchUrlAfterContent(string content)
83
92
var match = regex . Match ( content ) ;
84
93
Assert . Equal ( "http://www.localhost:8080" , match . Value . ToLowerInvariant ( ) ) ;
85
94
}
95
+
96
+ [ Theory ]
97
+ [ InlineData ( "http://www.localhost:8080!" , "http://www.localhost:8080!" ) ]
98
+ [ InlineData ( "http://www.localhost:8080/path!" , "http://www.localhost:8080/path!" ) ]
99
+ [ InlineData ( "http://www.localhost:8080/path;" , "http://www.localhost:8080/path" ) ]
100
+ [ InlineData ( "http://www.localhost:8080;" , "http://www.localhost:8080" ) ]
101
+ [ InlineData ( "http://www.local;host:8080;" , "http://www.local" ) ]
102
+ public void GenerateUrlRegEx_MatchUrlBeforeContent ( string content , string expected )
103
+ {
104
+ var regex = UrlParser . GenerateUrlRegEx ( ) ;
105
+ var match = regex . Match ( content ) ;
106
+ Assert . Equal ( expected , match . Value . ToLowerInvariant ( ) ) ;
107
+ }
86
108
}
0 commit comments