Use TrimStart rather than a loop to remove leading slashes in autoroute driver.

This commit is contained in:
Bertrand Le Roy
2014-12-03 22:02:18 -08:00
parent bd605810a8
commit d7edef9bb8

View File

@@ -81,9 +81,9 @@ namespace Orchard.Autoroute.Drivers {
var previous = part.DisplayAlias;
if (updater != null && updater.TryUpdateModel(viewModel, Prefix, null, null)) {
// remove any trailing slash in the permalink
while(!string.IsNullOrEmpty(viewModel.CurrentUrl) && viewModel.CurrentUrl.StartsWith("/")) {
viewModel.CurrentUrl = viewModel.CurrentUrl.Substring(1);
// remove any leading slash in the permalink
if (viewModel.CurrentUrl != null) {
viewModel.CurrentUrl = viewModel.CurrentUrl.TrimStart('/');
}
part.DisplayAlias = viewModel.CurrentUrl;