@@ -99,14 +99,30 @@ public Tag ToTagClient(LibGit2Sharp.Tag tag)
9999 // First, filter by search term if provided
100100 if ( ! string . IsNullOrEmpty ( query . Search ) )
101101 {
102- tags = query . Search switch
102+ var search = query . Search ;
103+ var startsWithCaret = search . StartsWith ( "^" , StringComparison . Ordinal ) ;
104+ var endsWithDollar = search . EndsWith ( "$" , StringComparison . Ordinal ) ;
105+
106+ if ( ! startsWithCaret && ! endsWithDollar )
107+ {
108+ tags = tags . Where ( t => t . FriendlyName . Contains ( search , StringComparison . OrdinalIgnoreCase ) ) ;
109+ }
110+ else
103111 {
104- string search when search . StartsWith ( "^" , StringComparison . Ordinal ) =>
105- tags . Where ( t => t . FriendlyName . StartsWith ( search [ 1 ..] , StringComparison . OrdinalIgnoreCase ) ) ,
106- string search when search . EndsWith ( "$" , StringComparison . Ordinal ) =>
107- tags . Where ( t => t . FriendlyName . EndsWith ( search [ ..^ 1 ] , StringComparison . OrdinalIgnoreCase ) ) ,
108- _ => tags . Where ( t => t . FriendlyName . Contains ( query . Search , StringComparison . OrdinalIgnoreCase ) ) ,
109- } ;
112+ // Remove the special characters for the actual search term
113+ if ( startsWithCaret )
114+ search = search [ 1 ..] ;
115+
116+ if ( endsWithDollar )
117+ search = search [ ..^ 1 ] ;
118+
119+ // Search with the appropriate conditions based on the presence of ^ and $
120+ if ( startsWithCaret )
121+ tags = tags . Where ( t => t . FriendlyName . StartsWith ( search , StringComparison . OrdinalIgnoreCase ) ) ;
122+
123+ if ( endsWithDollar )
124+ tags = tags . Where ( t => t . FriendlyName . EndsWith ( search , StringComparison . OrdinalIgnoreCase ) ) ;
125+ }
110126 }
111127
112128 var orderBy = query . OrderBy ? . ToLowerInvariant ( ) ;
0 commit comments