Skip to content

Commit 1bf6b1b

Browse files
committed
- Old case was failing tests. 105225
1 parent acd020e commit 1bf6b1b

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -351,15 +351,14 @@ internal string GetGxRouteValue(string path)
351351
}
352352
public bool ServiceInPath(String path, out String actualPath)
353353
{
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);
354+
string tmppath = path.Substring(0, 1).Equals("/") ? path.Substring(1) : path;
355+
int pos = tmppath.IndexOf("/");
356+
string innerPath = tmppath.Substring(pos, tmppath.Length - pos);
357+
actualPath = FindPath( innerPath, servicesPathUrl, true);
359358
if (String.IsNullOrEmpty(actualPath))
360359
{
361360
// fallback
362-
actualPath = FindPath(path, servicesPathUrl);
361+
actualPath = FindPath(path, servicesPathUrl, false);
363362
if (String.IsNullOrEmpty(actualPath))
364363
{
365364
actualPath = String.Empty;
@@ -376,16 +375,21 @@ public bool ServiceInPath(String path, out String actualPath)
376375
}
377376
}
378377

379-
private String FindPath(string innerPath, Dictionary<string,string > servicesPathUrl)
378+
private String FindPath(string innerPath, Dictionary<string,string > servicesPathUrl, bool startTxt)
380379
{
381380
string actualPath = String.Empty;
382-
foreach (var subPath in from String subPath in servicesPathUrl.Keys
383-
where innerPath.ToLower().StartsWith($"/{subPath.ToLower()}")
381+
foreach (var subPath in from String subPath in servicesPathUrl.Keys
384382
select subPath)
385383
{
386-
actualPath = subPath.ToLower();
387-
GXLogging.Debug(log, $"ServiceInPath actualPath:{actualPath}");
388-
return subPath;
384+
bool match = false;
385+
innerPath = innerPath.ToLower();
386+
match = (startTxt)? innerPath.StartsWith($"/{subPath.ToLower()}"): innerPath.Contains($"/{subPath.ToLower()}");
387+
if (match)
388+
{
389+
actualPath = subPath.ToLower();
390+
GXLogging.Debug(log, $"ServiceInPath actualPath:{actualPath}");
391+
return subPath;
392+
}
389393
}
390394
return null;
391395
}

0 commit comments

Comments
 (0)