@@ -126,6 +126,22 @@ public void StartsWithSegments_DoesACaseInsensitiveMatch(string sourcePath, stri
126
126
Assert . Equal ( expectedResult , result ) ;
127
127
}
128
128
129
+ [ Theory ]
130
+ [ InlineData ( "/a/" , "/a/" , true ) ]
131
+ [ InlineData ( "/a/b" , "/a/" , false ) ]
132
+ [ InlineData ( "/a/b/" , "/a/" , false ) ]
133
+ [ InlineData ( "/a//b" , "/a/" , true ) ]
134
+ [ InlineData ( "/a//b/" , "/a/" , true ) ]
135
+ public void StartsWithSegments_DoesMatchExactPathOrPathWithExtraTrailingSlash ( string sourcePath , string testPath , bool expectedResult )
136
+ {
137
+ var source = new PathString ( sourcePath ) ;
138
+ var test = new PathString ( testPath ) ;
139
+
140
+ var result = source . StartsWithSegments ( test ) ;
141
+
142
+ Assert . Equal ( expectedResult , result ) ;
143
+ }
144
+
129
145
[ Theory ]
130
146
[ InlineData ( "/test/path" , "/TEST" , true ) ]
131
147
[ InlineData ( "/test/path" , "/TEST/pa" , false ) ]
@@ -142,6 +158,22 @@ public void StartsWithSegmentsWithRemainder_DoesACaseInsensitiveMatch(string sou
142
158
Assert . Equal ( expectedResult , result ) ;
143
159
}
144
160
161
+ [ Theory ]
162
+ [ InlineData ( "/a/" , "/a/" , true ) ]
163
+ [ InlineData ( "/a/b" , "/a/" , false ) ]
164
+ [ InlineData ( "/a/b/" , "/a/" , false ) ]
165
+ [ InlineData ( "/a//b" , "/a/" , true ) ]
166
+ [ InlineData ( "/a//b/" , "/a/" , true ) ]
167
+ public void StartsWithSegmentsWithRemainder_DoesMatchExactPathOrPathWithExtraTrailingSlash ( string sourcePath , string testPath , bool expectedResult )
168
+ {
169
+ var source = new PathString ( sourcePath ) ;
170
+ var test = new PathString ( testPath ) ;
171
+
172
+ var result = source . StartsWithSegments ( test , out var remaining ) ;
173
+
174
+ Assert . Equal ( expectedResult , result ) ;
175
+ }
176
+
145
177
[ Theory ]
146
178
[ InlineData ( "/test/path" , "/TEST" , StringComparison . OrdinalIgnoreCase , true ) ]
147
179
[ InlineData ( "/test/path" , "/TEST" , StringComparison . Ordinal , false ) ]
@@ -163,6 +195,27 @@ public void StartsWithSegments_DoesMatchUsingSpecifiedComparison(string sourcePa
163
195
Assert . Equal ( expectedResult , result ) ;
164
196
}
165
197
198
+ [ Theory ]
199
+ [ InlineData ( "/a/" , "/a/" , StringComparison . OrdinalIgnoreCase , true ) ]
200
+ [ InlineData ( "/a/" , "/a/" , StringComparison . Ordinal , true ) ]
201
+ [ InlineData ( "/a/b" , "/a/" , StringComparison . OrdinalIgnoreCase , false ) ]
202
+ [ InlineData ( "/a/b" , "/a/" , StringComparison . Ordinal , false ) ]
203
+ [ InlineData ( "/a/b/" , "/a/" , StringComparison . OrdinalIgnoreCase , false ) ]
204
+ [ InlineData ( "/a/b/" , "/a/" , StringComparison . Ordinal , false ) ]
205
+ [ InlineData ( "/a//b" , "/a/" , StringComparison . OrdinalIgnoreCase , true ) ]
206
+ [ InlineData ( "/a//b" , "/a/" , StringComparison . Ordinal , true ) ]
207
+ [ InlineData ( "/a//b/" , "/a/" , StringComparison . OrdinalIgnoreCase , true ) ]
208
+ [ InlineData ( "/a//b/" , "/a/" , StringComparison . Ordinal , true ) ]
209
+ public void StartsWithSegments_DoesMatchExactPathOrPathWithExtraTrailingSlashUsingSpecifiedComparison ( string sourcePath , string testPath , StringComparison comparison , bool expectedResult )
210
+ {
211
+ var source = new PathString ( sourcePath ) ;
212
+ var test = new PathString ( testPath ) ;
213
+
214
+ var result = source . StartsWithSegments ( test , comparison ) ;
215
+
216
+ Assert . Equal ( expectedResult , result ) ;
217
+ }
218
+
166
219
[ Theory ]
167
220
[ InlineData ( "/test/path" , "/TEST" , StringComparison . OrdinalIgnoreCase , true ) ]
168
221
[ InlineData ( "/test/path" , "/TEST" , StringComparison . Ordinal , false ) ]
@@ -184,6 +237,27 @@ public void StartsWithSegmentsWithRemainder_DoesMatchUsingSpecifiedComparison(st
184
237
Assert . Equal ( expectedResult , result ) ;
185
238
}
186
239
240
+ [ Theory ]
241
+ [ InlineData ( "/a/" , "/a/" , StringComparison . OrdinalIgnoreCase , true ) ]
242
+ [ InlineData ( "/a/" , "/a/" , StringComparison . Ordinal , true ) ]
243
+ [ InlineData ( "/a/b" , "/a/" , StringComparison . OrdinalIgnoreCase , false ) ]
244
+ [ InlineData ( "/a/b" , "/a/" , StringComparison . Ordinal , false ) ]
245
+ [ InlineData ( "/a/b/" , "/a/" , StringComparison . OrdinalIgnoreCase , false ) ]
246
+ [ InlineData ( "/a/b/" , "/a/" , StringComparison . Ordinal , false ) ]
247
+ [ InlineData ( "/a//b" , "/a/" , StringComparison . OrdinalIgnoreCase , true ) ]
248
+ [ InlineData ( "/a//b" , "/a/" , StringComparison . Ordinal , true ) ]
249
+ [ InlineData ( "/a//b/" , "/a/" , StringComparison . OrdinalIgnoreCase , true ) ]
250
+ [ InlineData ( "/a//b/" , "/a/" , StringComparison . Ordinal , true ) ]
251
+ public void StartsWithSegmentsWithRemainder_DoesMatchExactPathOrPathWithExtraTrailingSlashUsingSpecifiedComparison ( string sourcePath , string testPath , StringComparison comparison , bool expectedResult )
252
+ {
253
+ var source = new PathString ( sourcePath ) ;
254
+ var test = new PathString ( testPath ) ;
255
+
256
+ var result = source . StartsWithSegments ( test , comparison , out var remaining ) ;
257
+
258
+ Assert . Equal ( expectedResult , result ) ;
259
+ }
260
+
187
261
[ Theory ]
188
262
// unreserved
189
263
[ InlineData ( "/abc123.-_~" , "/abc123.-_~" ) ]
0 commit comments