Skip to content

Commit dd67e30

Browse files
committed
Removing extra preceding '/' in routes when RoutePrefix is empty
Resolves #245
1 parent ec888ca commit dd67e30

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

SlackNet.AspNetCore/SlackRequestMiddleware.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,17 @@ public SlackRequestMiddleware(
2222

2323
public async Task Invoke(HttpContext context)
2424
{
25-
if (context.Request.Path == $"/{_configuration.RoutePrefix}/event")
25+
var root = _configuration.RoutePrefix == string.Empty
26+
? string.Empty
27+
: $"/{_configuration.RoutePrefix}";
28+
29+
if (context.Request.Path == $"{root}/event")
2630
await Respond(context.Response, await _requestHandler.HandleEventRequest(context.Request).ConfigureAwait(false)).ConfigureAwait(false);
27-
else if (context.Request.Path == $"/{_configuration.RoutePrefix}/action")
31+
else if (context.Request.Path == $"{root}/action")
2832
await Respond(context.Response, await _requestHandler.HandleActionRequest(context.Request).ConfigureAwait(false)).ConfigureAwait(false);
29-
else if (context.Request.Path == $"/{_configuration.RoutePrefix}/options")
33+
else if (context.Request.Path == $"{root}/options")
3034
await Respond(context.Response, await _requestHandler.HandleOptionsRequest(context.Request).ConfigureAwait(false)).ConfigureAwait(false);
31-
else if (context.Request.Path == $"/{_configuration.RoutePrefix}/command")
35+
else if (context.Request.Path == $"{root}/command")
3236
await Respond(context.Response, await _requestHandler.HandleSlashCommandRequest(context.Request).ConfigureAwait(false)).ConfigureAwait(false);
3337
else
3438
await _next(context).ConfigureAwait(false);

0 commit comments

Comments
 (0)