Invalid pathBase in RedirectRule
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 276
Description
### Describe the bug
I found a bug about pathBase in RedirectRule class. (namespace: Microsoft.AspNetCore.Rewrite.Internal)
If I use pathBase in my project and set an absolute URL to the replacement parameter, an error occurs.
### To Reproduce
Steps to reproduce the behavior:
1. Using this version of ASP.NET Core App '2.2.0'
2. Run this code
public async Task CheckRewritePath(string pathBase, string regex, string replacement, string expected)
{
// Arrange
var options = new RewriteOptions().Add(new RedirectRule(regex, replacement, StatusCodes.Status302Found));
var builder = new WebHostBuilder().Configure(app => { app.UsePathBase(pathBase); app.UseRewriter(options); });
var server = new TestServer(builder);
// Act
var response = await server.CreateClient().GetAsync(pathBase + "/" + regex);
// Assert
Assert.Equal(expected, response.Headers.Location.OriginalString);
}
3. With these arguments
[Theory]
[InlineData("/Test", "RedirectRule1", "https://localhost/Test/Home/Index", "https://localhost/Test/Home/Index")]
[InlineData("/Test", "RedirectRule2", "/Home/Index", "/Test/Home/Index")]
[InlineData("/Test", "RedirectRule3", "Home/Index", "/Test/Home/Index")]
4. See error
respons.Headers.Location.OrinalString returned /Testhttps://localhost/Test/RedirectRule
### Expected behavior
I expected to redirect absolute URL.
ex) https://localhost/Test/Home/Index
### Screenshots

Contributor guide
Assessment
This issue has not been assessed yet.