Skip to content

Commit acd020e

Browse files
committed
- Fix nested url issue with API Object. 105225
1 parent 7343dde commit acd020e

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRouting.cs

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,19 +351,45 @@ internal string GetGxRouteValue(string path)
351351
}
352352
public bool ServiceInPath(String path, out String actualPath)
353353
{
354-
actualPath = string.Empty;
355-
foreach (String subPath in servicesPathUrl.Keys)
354+
path = path.Substring(0, 1).Equals("/") ? path.Substring(1) : path;
355+
int pos = path.IndexOf("/");
356+
string innerPath = path.Substring(pos, path.Length - pos);
357+
358+
actualPath = FindPath( innerPath, servicesPathUrl);
359+
if (String.IsNullOrEmpty(actualPath))
356360
{
357-
if (path.ToLower().Contains($"/{subPath.ToLower()}"))
361+
// fallback
362+
actualPath = FindPath(path, servicesPathUrl);
363+
if (String.IsNullOrEmpty(actualPath))
364+
{
365+
actualPath = String.Empty;
366+
GXLogging.Debug(log, $"ServiceInPath path:{path} not found");
367+
return false;
368+
}
369+
else
358370
{
359-
actualPath = subPath.ToLower();
360-
GXLogging.Debug(log, $"ServiceInPath actualPath:{actualPath}");
361371
return true;
362372
}
363373
}
364-
GXLogging.Debug(log, $"ServiceInPath path:{path} not found");
365-
return false;
374+
else {
375+
return true;
376+
}
366377
}
378+
379+
private String FindPath(string innerPath, Dictionary<string,string > servicesPathUrl)
380+
{
381+
string actualPath = String.Empty;
382+
foreach (var subPath in from String subPath in servicesPathUrl.Keys
383+
where innerPath.ToLower().StartsWith($"/{subPath.ToLower()}")
384+
select subPath)
385+
{
386+
actualPath = subPath.ToLower();
387+
GXLogging.Debug(log, $"ServiceInPath actualPath:{actualPath}");
388+
return subPath;
389+
}
390+
return null;
391+
}
392+
367393
public GxRestWrapper GetController(HttpContext context, string controller, string methodName, Dictionary<string, string> variableAlias)
368394
{
369395
return GetController(context, new ControllerInfo() { Name = controller, MethodName = methodName, VariableAlias = variableAlias });

0 commit comments

Comments
 (0)