Skip to content

Commit

Permalink
Fixed: 'Action' and 'Controller' was left undashed if they are not me…
Browse files Browse the repository at this point in the history
…ntioned in @Url.RouteUrl
  • Loading branch information
salarcode committed Jan 6, 2017
1 parent 3514cd0 commit 308bf1e
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 13 deletions.
48 changes: 37 additions & 11 deletions LowercaseDashedRouting/LowercaseDashedRoute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,26 +115,52 @@ public override VirtualPathData GetVirtualPath(RequestContext requestContext, Ro
var originalController = values["controller"] as string;
string dashedAction = originalAction, dashedController = originalController;

if (originalAction != null)
values["action"] = dashedAction = AddDashesBeforeCapitals(originalAction).ToLowerInvariant();
if (originalController != null)
values["controller"] = dashedController = AddDashesBeforeCapitals(originalController).ToLowerInvariant();

// FIX: for when the 'action' is not mentioned and the default value which is stored in the RouteData is about to be used!
var currentValues = requestContext.RouteData.Values;
object current;

if (currentValues.TryGetValue("action", out current) &&
(current as string) == originalAction)
// Dashing the 'Action'
if (originalAction != null)
{
values["action"] = dashedAction = AddDashesBeforeCapitals(originalAction).ToLowerInvariant();

if (currentValues.TryGetValue("action", out current) &&
(current as string) == originalAction)
{
currentValues["action"] = dashedAction;
}
}
else
{
// Applying dash to route values
if (currentValues.TryGetValue("action", out current))
{
currentValues["action"] = AddDashesBeforeCapitals(current as string).ToLowerInvariant();
}
}

// Aash the 'Controller'
if (originalController != null)
{
currentValues["action"] = dashedAction;
values["controller"] = dashedController = AddDashesBeforeCapitals(originalController).ToLowerInvariant();

if (currentValues.TryGetValue("controller", out current) &&
(current as string) == originalController)
{
currentValues["controller"] = dashedController;
}
}
if (currentValues.TryGetValue("controller", out current) &&
(current as string) == originalController)
else
{
currentValues["controller"] = dashedController;
// Applying dash to route values
if (currentValues.TryGetValue("controller", out current))
{
currentValues["controller"] = AddDashesBeforeCapitals(current as string).ToLowerInvariant();
}
}



if (DataTokens["LowercaseDashedRoute"] == null)
{
Url = AddDashesForMatchingUrl(Url);
Expand Down
4 changes: 2 additions & 2 deletions LowercaseDashedRouting/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.3.3.0")]
[assembly: AssemblyFileVersion("1.3.3.0")]
[assembly: AssemblyVersion("1.4.0.0")]
[assembly: AssemblyFileVersion("1.4.0.0")]

0 comments on commit 308bf1e

Please sign in to comment.