Prevents throwing exception when Href is null (#8461)

This commit is contained in:
Hermes Sbicego
2021-03-19 08:13:06 +01:00
committed by GitHub
parent 3b9c5fef06
commit 089bc1d068

View File

@@ -124,7 +124,7 @@ namespace Orchard.UI.Navigation {
string appPath = currentRequest.ApplicationPath ?? "/";
string requestUrl = currentRequest.Path.StartsWith(appPath) ? currentRequest.Path.Substring(appPath.Length) : currentRequest.Path;
string modelUrl = menuItem.Href.Replace("~/", appPath);
string modelUrl = menuItem.Href?.Replace("~/", appPath) ?? "";
modelUrl = modelUrl.StartsWith(appPath) ? modelUrl.Substring(appPath.Length) : modelUrl;
if (requestUrl.Equals(modelUrl, StringComparison.OrdinalIgnoreCase) || (!string.IsNullOrEmpty(modelUrl) && requestUrl.StartsWith(modelUrl + "/", StringComparison.OrdinalIgnoreCase))) {