1
1
// Licensed to the .NET Foundation under one or more agreements.
2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
4
+ using System . Diagnostics . CodeAnalysis ;
4
5
using Microsoft . AspNetCore . Http ;
5
6
6
7
namespace Microsoft . AspNetCore . Rewrite ;
@@ -42,7 +43,7 @@ public static RewriteOptions Add(this RewriteOptions options, Action<RewriteCont
42
43
/// <param name="replacement">If the regex matches, what to replace the uri with.</param>
43
44
/// <param name="skipRemainingRules">If the regex matches, conditionally stop processing other rules.</param>
44
45
/// <returns>The Rewrite options.</returns>
45
- public static RewriteOptions AddRewrite ( this RewriteOptions options , string regex , string replacement , bool skipRemainingRules )
46
+ public static RewriteOptions AddRewrite ( this RewriteOptions options , [ StringSyntax ( StringSyntaxAttribute . Regex ) ] string regex , string replacement , bool skipRemainingRules )
46
47
{
47
48
options . Rules . Add ( new RewriteRule ( regex , replacement , skipRemainingRules ) ) ;
48
49
return options ;
@@ -55,7 +56,7 @@ public static RewriteOptions AddRewrite(this RewriteOptions options, string rege
55
56
/// <param name="regex">The regex string to compare with.</param>
56
57
/// <param name="replacement">If the regex matches, what to replace the uri with.</param>
57
58
/// <returns>The Rewrite options.</returns>
58
- public static RewriteOptions AddRedirect ( this RewriteOptions options , string regex , string replacement )
59
+ public static RewriteOptions AddRedirect ( this RewriteOptions options , [ StringSyntax ( StringSyntaxAttribute . Regex ) ] string regex , string replacement )
59
60
{
60
61
return AddRedirect ( options , regex , replacement , statusCode : StatusCodes . Status302Found ) ;
61
62
}
@@ -68,7 +69,7 @@ public static RewriteOptions AddRedirect(this RewriteOptions options, string reg
68
69
/// <param name="replacement">If the regex matches, what to replace the uri with.</param>
69
70
/// <param name="statusCode">The status code to add to the response.</param>
70
71
/// <returns>The Rewrite options.</returns>
71
- public static RewriteOptions AddRedirect ( this RewriteOptions options , string regex , string replacement , int statusCode )
72
+ public static RewriteOptions AddRedirect ( this RewriteOptions options , [ StringSyntax ( StringSyntaxAttribute . Regex ) ] string regex , string replacement , int statusCode )
72
73
{
73
74
options . Rules . Add ( new RedirectRule ( regex , replacement , statusCode ) ) ;
74
75
return options ;
0 commit comments