mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-25 10:59:18 +08:00
committed by
Sébastien Ros
parent
f5192d89c7
commit
3152bb131a
@@ -14,33 +14,39 @@ namespace Orchard.Conditions.Providers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void Evaluate(ConditionEvaluationContext evaluationContext) {
|
public void Evaluate(ConditionEvaluationContext evaluationContext) {
|
||||||
if (!String.Equals(evaluationContext.FunctionName, "url", StringComparison.OrdinalIgnoreCase))
|
if (!string.Equals(evaluationContext.FunctionName, "url", StringComparison.OrdinalIgnoreCase))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var context = _httpContextAccessor.Current();
|
var context = _httpContextAccessor.Current();
|
||||||
var url = Convert.ToString(evaluationContext.Arguments[0]);
|
foreach (var argument in evaluationContext.Arguments) {
|
||||||
if (url.StartsWith("~/")) {
|
var url = Convert.ToString(argument);
|
||||||
url = url.Substring(2);
|
if (url.StartsWith("~/")) {
|
||||||
var appPath = context.Request.ApplicationPath;
|
url = url.Substring(2);
|
||||||
if (appPath == "/")
|
var appPath = context.Request.ApplicationPath;
|
||||||
appPath = "";
|
if (appPath == "/")
|
||||||
|
appPath = "";
|
||||||
|
|
||||||
if(!String.IsNullOrEmpty(_shellSettings.RequestUrlPrefix))
|
if (!string.IsNullOrEmpty(_shellSettings.RequestUrlPrefix))
|
||||||
appPath = String.Concat(appPath, "/", _shellSettings.RequestUrlPrefix);
|
appPath = string.Concat(appPath, "/", _shellSettings.RequestUrlPrefix);
|
||||||
|
|
||||||
url = String.Concat(appPath, "/", url);
|
url = string.Concat(appPath, "/", url);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!url.Contains("?"))
|
||||||
|
url = url.TrimEnd('/');
|
||||||
|
|
||||||
|
var requestPath = context.Request.Path;
|
||||||
|
if (!requestPath.Contains("?"))
|
||||||
|
requestPath = requestPath.TrimEnd('/');
|
||||||
|
|
||||||
|
if ((url.EndsWith("*") && requestPath.StartsWith(url.TrimEnd('*'), StringComparison.OrdinalIgnoreCase)) ||
|
||||||
|
string.Equals(requestPath, url, StringComparison.OrdinalIgnoreCase)) {
|
||||||
|
evaluationContext.Result = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!url.Contains("?"))
|
evaluationContext.Result = false;
|
||||||
url = url.TrimEnd('/');
|
|
||||||
|
|
||||||
var requestPath = context.Request.Path;
|
|
||||||
if (!requestPath.Contains("?"))
|
|
||||||
requestPath = requestPath.TrimEnd('/');
|
|
||||||
|
|
||||||
evaluationContext.Result = url.EndsWith("*")
|
|
||||||
? requestPath.StartsWith(url.TrimEnd('*'), StringComparison.OrdinalIgnoreCase)
|
|
||||||
: string.Equals(requestPath, url, StringComparison.OrdinalIgnoreCase);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user