Skip to content

Commit

Permalink
Improved template normalization for CORS.
Browse files Browse the repository at this point in the history
  • Loading branch information
vmelamed committed Apr 7, 2016
1 parent d547e2e commit 9de1bf9
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>AspectExpressionSerialization</id>
<version>1.0.37</version>
<version>1.0.39</version>
<authors>Val Melamed</authors>
<owners>Val Melamed</owners>
<summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
[assembly: AssemblyTitle("vm.Aspects.Linq.Expressions.Serialization")]
[assembly: AssemblyDescription("Serializes and deserializes LINQ expression trees to and from XML documents.")]

[assembly: AssemblyVersion("1.0.37")]
[assembly: AssemblyFileVersion("1.0.37")]
[assembly: AssemblyInformationalVersion("1.0.37")]
[assembly: AssemblyVersion("1.0.39")]
[assembly: AssemblyFileVersion("1.0.39")]
[assembly: AssemblyInformationalVersion("1.0.39")]

[assembly: InternalsVisibleTo(
"vm.Aspects.Linq.Expressions.Serialization.Test, " +
Expand Down
6 changes: 3 additions & 3 deletions Aspects/Model/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[assembly: AssemblyTitle("vm.Aspect.Model")]
[assembly: AssemblyDescription("Defines the IRepository and related base classes and utilities - a framework of building domain object model.")]

[assembly: AssemblyVersion("1.0.37")]
[assembly: AssemblyFileVersion("1.0.37")]
[assembly: AssemblyInformationalVersion("1.0.37")]
[assembly: AssemblyVersion("1.0.39")]
[assembly: AssemblyFileVersion("1.0.39")]
[assembly: AssemblyInformationalVersion("1.0.39")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Model.Tests, " +
Expand Down
15 changes: 12 additions & 3 deletions Aspects/NuGet/vm.Aspects.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>vm.Aspects</id>
<version>1.0.37-beta</version>
<version>1.0.39-beta</version>
<authors>Val Melamed</authors>
<owners>Val Melamed</owners>
<summary>
Expand All @@ -12,8 +12,17 @@
A set of classes, utilities, etc. addressing various common cross-cutting concerns or extending existing similar libraries like Enterprise Library, Unity, etc.
</description>
<releaseNotes>
* Grouped all behaviors in the vm.Aspects.Wcf.Behaviors namespace.
* Fixed a bug in the ExceptionShieldingBehavior where the ExceptionManager was not instantiated.
* Camelcased the names of the properties in the fault messages.
* Added setters to the Money class' properties for work with DB-s. Added metadata.
* Added NonemptyGuidValidator.
* Added Regex-es: ISO 8601 dates and times, credit card validators, routing number validators, bug fixes.
* Added conventions for Numeric and String data annotation attributes and a convention for DateTime properties to map to SQL type datetime2.
* Added HttpStatusCode mapping tables and Exception to/from Fault mapping tables.
* Changed all CallContext.Set/GetData to Get/SetLogicalData.
* Added DisposeExtensions.
* CORS behavior for WebHttpBinding (WCF REST).
* Number of bug fixes.
* ImmutableAttribute.
</releaseNotes>
<licenseUrl>https://github.com/vmelamed/vm/blob/master/LICENSE</licenseUrl>
<projectUrl>https://github.com/vmelamed/vm/tree/master/Aspects</projectUrl>
Expand Down
6 changes: 3 additions & 3 deletions Aspects/Parsers/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
[assembly: AssemblyTitle("vm.Aspects.Parser")]
[assembly: AssemblyDescription("Text parsing readers, e.g. CSV/TSV reader.")]

[assembly: AssemblyVersion("1.0.37")]
[assembly: AssemblyFileVersion("1.0.37")]
[assembly: AssemblyInformationalVersion("1.0.37")]
[assembly: AssemblyVersion("1.0.39")]
[assembly: AssemblyFileVersion("1.0.39")]
[assembly: AssemblyInformationalVersion("1.0.39")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Parsers.Tests, " +
Expand Down
6 changes: 3 additions & 3 deletions Aspects/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

[assembly: AssemblyTitle("vm.Aspects")]
[assembly: AssemblyDescription("A set of classes addressing various common cross-cutting concerns.")]
[assembly: AssemblyVersion("1.0.37")]
[assembly: AssemblyFileVersion("1.0.37")]
[assembly: AssemblyInformationalVersion("1.0.37")]
[assembly: AssemblyVersion("1.0.39")]
[assembly: AssemblyFileVersion("1.0.39")]
[assembly: AssemblyInformationalVersion("1.0.39")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Test, " +
Expand Down
6 changes: 3 additions & 3 deletions Aspects/Wcf/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[assembly: AssemblyTitle("Wcf")]
[assembly: AssemblyDescription("A set of classes and generics simplifying the initial configuration work of creating WCF services.")]

[assembly: AssemblyVersion("1.0.37")]
[assembly: AssemblyFileVersion("1.0.37")]
[assembly: AssemblyInformationalVersion("1.0.37")]
[assembly: AssemblyVersion("1.0.39")]
[assembly: AssemblyFileVersion("1.0.39")]
[assembly: AssemblyInformationalVersion("1.0.39")]

[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(
"vm.Aspects.Wcf.Test, " +
Expand Down
20 changes: 6 additions & 14 deletions Aspects/Wcf/Services/ServiceHostExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Microsoft.Practices.ServiceLocation;
using System;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
Expand All @@ -10,6 +9,8 @@
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Web;
using System.Text.RegularExpressions;
using Microsoft.Practices.ServiceLocation;
using vm.Aspects.Wcf.Behaviors;
using vm.Aspects.Wcf.Bindings;

Expand Down Expand Up @@ -517,6 +518,8 @@ static void AddPreflightOperationSelectors(
}
}

static Regex _rexNamedParams = new Regex(@"{[^}]+}(?:/{[^}]+})*", RegexOptions.Compiled);

static string NormalizeTemplate(string uriTemplate)
{
Contract.Requires<ArgumentNullException>(uriTemplate != null, nameof(uriTemplate));
Expand All @@ -527,18 +530,7 @@ static string NormalizeTemplate(string uriTemplate)
// no query string used for this
uriTemplate = uriTemplate.Substring(0, queryIndex);

int paramIndex;

while ((paramIndex = uriTemplate.IndexOf('{')) >= 0)
{
// Replace all named parameters with wild-cards
int endParamIndex = uriTemplate.IndexOf('}', paramIndex);

if (endParamIndex >= 0)
uriTemplate = uriTemplate.Substring(0, paramIndex) + '*' + uriTemplate.Substring(endParamIndex + 1);
}

return uriTemplate;
return _rexNamedParams.Replace(uriTemplate, "*");
}
}
}

0 comments on commit 9de1bf9

Please sign in to comment.