Skip to content

Commit 360598e

Browse files
committed
Refactor error code handling in RedirectionService
1 parent cf5dec5 commit 360598e

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

LinkRouter/App/Services/RedirectionService.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,8 @@ public async Task<ActionResult> GetRedirect(string path)
2222
{
2323
var url = Config.RootRoute;
2424

25-
if (Config.ErrorCodePattern.IsMatch(url))
26-
{
27-
var errorCodeMatch = Config.ErrorCodePattern.Match(url);
28-
var errorCode = int.Parse(errorCodeMatch.Groups[1].Value);
29-
return new StatusCodeResult(errorCode);
30-
}
25+
if (TryGetErrorCode(url, out var notFoundStatusCode))
26+
return new StatusCodeResult(notFoundStatusCode);
3127

3228
await MetricsService.IncrementFound("/");
3329

0 commit comments

Comments
 (0)