From 3e119a87be97a8c8b7c13ebc76865fe990251437 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Wed, 28 Sep 2016 17:57:49 -0600 Subject: [PATCH] Remove rewrite rule API with default assumptions about skip remaining rules (#105) --- samples/RewriteSample/Startup.cs | 2 +- .../RewriteOptionsExtensions.cs | 16 ++-------------- .../MiddlewareTests.cs | 4 ++-- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/samples/RewriteSample/Startup.cs b/samples/RewriteSample/Startup.cs index e1285d0666..7ef08d2f99 100644 --- a/samples/RewriteSample/Startup.cs +++ b/samples/RewriteSample/Startup.cs @@ -15,7 +15,7 @@ namespace RewriteSample { var options = new RewriteOptions() .AddRedirect("(.*)/$", "$1") - .AddRewrite(@"app/(\d+)", "app?id=$1") + .AddRewrite(@"app/(\d+)", "app?id=$1", skipRemainingRules: false) .AddRedirectToHttps(302, 5001) .AddIISUrlRewrite(env.ContentRootFileProvider, "UrlRewrite.xml") .AddApacheModRewrite(env.ContentRootFileProvider, "Rewrite.txt"); diff --git a/src/Microsoft.AspNetCore.Rewrite/RewriteOptionsExtensions.cs b/src/Microsoft.AspNetCore.Rewrite/RewriteOptionsExtensions.cs index b1b4057cd4..550d6e8211 100644 --- a/src/Microsoft.AspNetCore.Rewrite/RewriteOptionsExtensions.cs +++ b/src/Microsoft.AspNetCore.Rewrite/RewriteOptionsExtensions.cs @@ -1,4 +1,4 @@ -// Copyright (c) .NET Foundation. All rights reserved. +// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -36,19 +36,7 @@ namespace Microsoft.AspNetCore.Rewrite } /// - /// Rewrites the path if the regex matches the HttpContext's PathString - /// - /// The . - /// The regex string to compare with. - /// If the regex matches, what to replace HttpContext with. - /// The Rewrite options. - public static RewriteOptions AddRewrite(this RewriteOptions options, string regex, string replacement) - { - return AddRewrite(options, regex, replacement, skipRemainingRules: false); - } - - /// - /// Rewrites the path if the regex matches the HttpContext's PathString + /// Adds a rule that rewrites the path if the regex matches the HttpContext's PathString. /// /// The . /// The regex string to compare with. diff --git a/test/Microsoft.AspNetCore.Rewrite.Tests/MiddlewareTests.cs b/test/Microsoft.AspNetCore.Rewrite.Tests/MiddlewareTests.cs index 9a6f4d9c46..67802e031f 100644 --- a/test/Microsoft.AspNetCore.Rewrite.Tests/MiddlewareTests.cs +++ b/test/Microsoft.AspNetCore.Rewrite.Tests/MiddlewareTests.cs @@ -16,7 +16,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.CodeRules [Fact] public async Task CheckRewritePath() { - var options = new RewriteOptions().AddRewrite("(.*)", "http://example.com/$1"); + var options = new RewriteOptions().AddRewrite("(.*)", "http://example.com/$1", skipRemainingRules: false); var builder = new WebHostBuilder() .Configure(app => { @@ -87,7 +87,7 @@ namespace Microsoft.AspNetCore.Rewrite.Tests.CodeRules [Fact] public async Task CheckIfEmptyStringRewriteCorrectly() { - var options = new RewriteOptions().AddRewrite("(.*)", "$1"); + var options = new RewriteOptions().AddRewrite("(.*)", "$1", skipRemainingRules: false); var builder = new WebHostBuilder() .Configure(app => {