File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,14 +54,10 @@ public void CompileRoutes()
5454 var replacements = new List < ( int Index , int Length , string NewText ) > ( ) ;
5555
5656 var escaped = Regex . Escape ( route . Route ) ;
57-
58- Console . WriteLine ( escaped ) ;
5957
60- var pattern = new Regex ( @"\\\{(\d|\w+)\}" ) ;
58+ var pattern = new Regex ( @"\\\{(\d|\w+)\}" , RegexOptions . CultureInvariant ) ;
6159
6260 var matches = pattern . Matches ( escaped ) ;
63-
64- Console . WriteLine ( matches . Count + " matches found." ) ;
6561
6662 foreach ( var match in matches . Select ( x => x ) )
6763 {
@@ -86,8 +82,6 @@ public void CompileRoutes()
8682 compiled . CompiledPattern = new Regex ( compiledRouteBuilder . ToString ( ) ,
8783 RegexOptions . Compiled | RegexOptions . CultureInvariant ) ;
8884
89- Console . WriteLine ( compiled . CompiledPattern . ToString ( ) ) ;
90-
9185 var duplicate = matches
9286 . Select ( ( m , i ) => m . Groups [ 1 ] . Value )
9387 . GroupBy ( x => x )
Original file line number Diff line number Diff line change @@ -54,7 +54,13 @@ public async Task<ActionResult> RedirectToExternalUrl(string path)
5454 . Inc ( ) ;
5555
5656 if ( Config . NotFoundBehavior . RedirectOn404 )
57- return Redirect ( Config . NotFoundBehavior . RedirectUrl ) ;
57+ if ( Config . ErrorCodePattern . IsMatch ( Config . NotFoundBehavior . RedirectUrl ) )
58+ {
59+ var errorCodeMatch = Config . ErrorCodePattern . Match ( Config . NotFoundBehavior . RedirectUrl ) ;
60+ var errorCode = int . Parse ( errorCodeMatch . Groups [ 1 ] . Value ) ;
61+ return StatusCode ( errorCode ) ;
62+ } else
63+ return Redirect ( Config . NotFoundBehavior . RedirectUrl ) ;
5864
5965 return NotFound ( ) ;
6066 }
@@ -87,6 +93,13 @@ public IActionResult GetRootRoute()
8793 . Inc ( ) ;
8894
8995 string url = Config . RootRoute ;
96+
97+ if ( Config . ErrorCodePattern . IsMatch ( url ) )
98+ {
99+ var errorCodeMatch = Config . ErrorCodePattern . Match ( url ) ;
100+ var errorCode = int . Parse ( errorCodeMatch . Groups [ 1 ] . Value ) ;
101+ return StatusCode ( errorCode ) ;
102+ }
90103
91104 return Redirect ( url ) ;
92105 }
You can’t perform that action at this time.
0 commit comments