diff --git a/src/Microsoft.IIS.Administration.WebServer.UrlRewrite/Configuration/OutboundRules/OutboundRuleMatchType.cs b/src/Microsoft.IIS.Administration.WebServer.UrlRewrite/Configuration/OutboundRules/OutboundRuleMatchType.cs index 88903bc..4786afe 100644 --- a/src/Microsoft.IIS.Administration.WebServer.UrlRewrite/Configuration/OutboundRules/OutboundRuleMatchType.cs +++ b/src/Microsoft.IIS.Administration.WebServer.UrlRewrite/Configuration/OutboundRules/OutboundRuleMatchType.cs @@ -10,7 +10,7 @@ namespace Microsoft.IIS.Administration.WebServer.UrlRewrite // Keep public for resolution of enums from 'dynamic' types in helper classes i.e. DynamicHelper public enum OutboundRuleMatchType { ServerVariable, - Tags + Response } static class OutboundMatchTypeHelper @@ -20,8 +20,8 @@ namespace Microsoft.IIS.Administration.WebServer.UrlRewrite switch (matchType) { case OutboundRuleMatchType.ServerVariable: return "server_variable"; - case OutboundRuleMatchType.Tags: - return "tags"; + case OutboundRuleMatchType.Response: + return "response"; default: throw new ArgumentException(nameof(matchType)); } @@ -32,8 +32,8 @@ namespace Microsoft.IIS.Administration.WebServer.UrlRewrite switch (model.ToLowerInvariant()) { case "server_variable": return OutboundRuleMatchType.ServerVariable; - case "tags": - return OutboundRuleMatchType.Tags; + case "response": + return OutboundRuleMatchType.Response; default: throw new ApiArgumentException("match_type"); } diff --git a/src/Microsoft.IIS.Administration.WebServer.UrlRewrite/Helpers/OutboundRulesHelper.cs b/src/Microsoft.IIS.Administration.WebServer.UrlRewrite/Helpers/OutboundRulesHelper.cs index b4849a1..34631e6 100644 --- a/src/Microsoft.IIS.Administration.WebServer.UrlRewrite/Helpers/OutboundRulesHelper.cs +++ b/src/Microsoft.IIS.Administration.WebServer.UrlRewrite/Helpers/OutboundRulesHelper.cs @@ -296,17 +296,16 @@ namespace Microsoft.IIS.Administration.WebServer.UrlRewrite obj.server_variable = string.IsNullOrEmpty(rule.Match.ServerVariable) ? null : rule.Match.ServerVariable; } - // tags - if (fields.Exists("tags") && matchType == OutboundRuleMatchType.Tags) { - // - // dynamic ExpandoObject - obj.tags = CreateTagsModel(rule.Match.FilterByTags); + // tag_filters + if (fields.Exists("tag_filters") && matchType == OutboundRuleMatchType.Response) { + + obj.tag_filters = CreateTagsModel(rule.Match.FilterByTags); TagsElement customTags = rule.Match.FilterByTags.HasFlag(FilterByTags.CustomTags) ? section.Tags.FirstOrDefault(t => t.Name.Equals(rule.Match.CustomTags, StringComparison.OrdinalIgnoreCase)) : null; - obj.tags.custom = customTags == null ? null : TagsToJsonModelRef(customTags, site, path, fields.Filter("tags.custom")); + obj.tag_filters.custom = customTags == null ? null : TagsToJsonModelRef(customTags, site, path, fields.Filter("tag_filters.custom")); } // @@ -668,7 +667,7 @@ namespace Microsoft.IIS.Administration.WebServer.UrlRewrite private static OutboundRuleMatchType GetMatchType(OutboundRule rule) { - return string.IsNullOrEmpty(rule.Match.ServerVariable) ? OutboundRuleMatchType.Tags : OutboundRuleMatchType.ServerVariable; + return string.IsNullOrEmpty(rule.Match.ServerVariable) ? OutboundRuleMatchType.Response : OutboundRuleMatchType.ServerVariable; } private static void SetRule(dynamic model, OutboundRule rule, OutboundRulesSection section) @@ -717,17 +716,17 @@ namespace Microsoft.IIS.Administration.WebServer.UrlRewrite // // Html Tags - dynamic tags = null; + dynamic tagFilters = null; dynamic customTags = null; - if (model.tags != null) { - tags = model.tags; + if (model.tag_filters != null) { + tagFilters = model.tag_filters; - if (!(tags is JObject)) { - throw new ApiArgumentException("tags", ApiArgumentException.EXPECTED_OBJECT); + if (!(tagFilters is JObject)) { + throw new ApiArgumentException("tag_filters", ApiArgumentException.EXPECTED_OBJECT); } - customTags = tags.custom; + customTags = tagFilters.custom; // Clear custom tags rule.Match.CustomTags = null; @@ -735,20 +734,20 @@ namespace Microsoft.IIS.Administration.WebServer.UrlRewrite } // Set standard tags - if (tags != null) { + if (tagFilters != null) { FilterByTags ruleTags = rule.Match.FilterByTags; - DynamicHelper.If((object)tags.a, v => SetTagFlag(ref ruleTags, FilterByTags.A, v)); - DynamicHelper.If((object)tags.area, v => SetTagFlag(ref ruleTags, FilterByTags.Area, v)); - DynamicHelper.If((object)tags.@base, v => SetTagFlag(ref ruleTags, FilterByTags.Base, v)); - DynamicHelper.If((object)tags.form, v => SetTagFlag(ref ruleTags, FilterByTags.Form, v)); - DynamicHelper.If((object)tags.frame, v => SetTagFlag(ref ruleTags, FilterByTags.Frame, v)); - DynamicHelper.If((object)tags.head, v => SetTagFlag(ref ruleTags, FilterByTags.Head, v)); - DynamicHelper.If((object)tags.iframe, v => SetTagFlag(ref ruleTags, FilterByTags.IFrame, v)); - DynamicHelper.If((object)tags.img, v => SetTagFlag(ref ruleTags, FilterByTags.Img, v)); - DynamicHelper.If((object)tags.input, v => SetTagFlag(ref ruleTags, FilterByTags.Input, v)); - DynamicHelper.If((object)tags.link, v => SetTagFlag(ref ruleTags, FilterByTags.Link, v)); - DynamicHelper.If((object)tags.script, v => SetTagFlag(ref ruleTags, FilterByTags.Script, v)); + DynamicHelper.If((object)tagFilters.a, v => SetTagFlag(ref ruleTags, FilterByTags.A, v)); + DynamicHelper.If((object)tagFilters.area, v => SetTagFlag(ref ruleTags, FilterByTags.Area, v)); + DynamicHelper.If((object)tagFilters.@base, v => SetTagFlag(ref ruleTags, FilterByTags.Base, v)); + DynamicHelper.If((object)tagFilters.form, v => SetTagFlag(ref ruleTags, FilterByTags.Form, v)); + DynamicHelper.If((object)tagFilters.frame, v => SetTagFlag(ref ruleTags, FilterByTags.Frame, v)); + DynamicHelper.If((object)tagFilters.head, v => SetTagFlag(ref ruleTags, FilterByTags.Head, v)); + DynamicHelper.If((object)tagFilters.iframe, v => SetTagFlag(ref ruleTags, FilterByTags.IFrame, v)); + DynamicHelper.If((object)tagFilters.img, v => SetTagFlag(ref ruleTags, FilterByTags.Img, v)); + DynamicHelper.If((object)tagFilters.input, v => SetTagFlag(ref ruleTags, FilterByTags.Input, v)); + DynamicHelper.If((object)tagFilters.link, v => SetTagFlag(ref ruleTags, FilterByTags.Link, v)); + DynamicHelper.If((object)tagFilters.script, v => SetTagFlag(ref ruleTags, FilterByTags.Script, v)); rule.Match.FilterByTags = ruleTags; } @@ -843,7 +842,7 @@ namespace Microsoft.IIS.Administration.WebServer.UrlRewrite string type = DynamicHelper.Value(model.match_type); OutboundRuleMatchType matchType = string.IsNullOrEmpty(type) ? GetMatchType(rule) : OutboundMatchTypeHelper.FromJsonModel(type); - if (matchType == OutboundRuleMatchType.Tags) { + if (matchType == OutboundRuleMatchType.Response) { rule.Match.ServerVariable = null; } else { diff --git a/test/Microsoft.IIS.Administration.Tests/UrlRewrite.cs b/test/Microsoft.IIS.Administration.Tests/UrlRewrite.cs index 05423b2..37653bf 100644 --- a/test/Microsoft.IIS.Administration.Tests/UrlRewrite.cs +++ b/test/Microsoft.IIS.Administration.Tests/UrlRewrite.cs @@ -529,8 +529,8 @@ namespace Microsoft.IIS.Administration.Tests JObject outboundRule = JObject.FromObject(new { name = testName, - match_type = "tags", - tags = new { + match_type = "response", + tag_filters = new { a = true, area = true, @base = true, @@ -1106,10 +1106,10 @@ namespace Microsoft.IIS.Administration.Tests } // - // Html Tags - if (a["tags"] != null || b["tags"] != null) { - JObject aTags = a.Value("tags"); - JObject bTags = b.Value("tags"); + // Tag Filters + if (a["tag_filters"] != null || b["tag_filters"] != null) { + JObject aTags = a.Value("tag_filters"); + JObject bTags = b.Value("tag_filters"); Assert.Equal(aTags.Value("a"), bTags.Value("a")); Assert.Equal(aTags.Value("area"), bTags.Value("area")); @@ -1123,8 +1123,8 @@ namespace Microsoft.IIS.Administration.Tests Assert.Equal(aTags.Value("link"), bTags.Value("link")); Assert.Equal(aTags.Value("script"), bTags.Value("script")); - if (a["tags"]["custom"] != null || b["tags"]["custom"] != null) { - Assert.Equal(a["tags"]["custom"].Value("id"), b["tags"]["custom"].Value("id")); + if (aTags["custom"] != null || bTags["custom"] != null) { + Assert.Equal(aTags["custom"].Value("id"), bTags["custom"].Value("id")); } }