Refactoring permalink redirection based on reviews

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2011-04-05 14:27:12 -07:00
parent 8c69f03ccb
commit 040c3d78d5

View File

@@ -299,13 +299,13 @@ namespace Orchard.Core.Contents.Controllers {
// store the previous route in case a back redirection is requested // store the previous route in case a back redirection is requested
string previousRoute = null; string previousRoute = null;
var route = contentItem.As<RoutePart>(); if(contentItem.Has<RoutePart>()
if(route != null
&&!string.IsNullOrWhiteSpace(returnUrl) &&!string.IsNullOrWhiteSpace(returnUrl)
&& Url.IsLocalUrl(returnUrl) && Url.IsLocalUrl(returnUrl)
&& returnUrl == Url.ItemDisplayUrl(contentItem) // only if the original returnUrl is the content itself // only if the original returnUrl is the content itself
&& String.Equals(returnUrl, Url.ItemDisplayUrl(contentItem), StringComparison.OrdinalIgnoreCase)
) { ) {
previousRoute = route.Path; previousRoute = contentItem.As<RoutePart>().Path;
} }
dynamic model = _contentManager.UpdateEditor(contentItem, this); dynamic model = _contentManager.UpdateEditor(contentItem, this);
@@ -320,7 +320,7 @@ namespace Orchard.Core.Contents.Controllers {
// did the route change ? // did the route change ?
if (!string.IsNullOrWhiteSpace(returnUrl) if (!string.IsNullOrWhiteSpace(returnUrl)
&& previousRoute != null && previousRoute != null
&& contentItem.As<RoutePart>().Path != previousRoute) { && !String.Equals(contentItem.As<RoutePart>().Path, previousRoute, StringComparison.OrdinalIgnoreCase)) {
returnUrl = Url.ItemDisplayUrl(contentItem); returnUrl = Url.ItemDisplayUrl(contentItem);
} }