diff --git a/src/core/Akka/Actor/ActorPath.cs b/src/core/Akka/Actor/ActorPath.cs index 05f862c4777..9c3fc0dfbfd 100644 --- a/src/core/Akka/Actor/ActorPath.cs +++ b/src/core/Akka/Actor/ActorPath.cs @@ -329,6 +329,15 @@ public static bool TryParse(string path, out ActorPath actorPath) if (!TryParseAddress(path, out var address, out var absoluteUri)) return false; var spanified = absoluteUri; + + // check for Uri fragment here + var fragment = ReadOnlySpan.Empty; + var fragLoc = spanified.IndexOf('#'); + if (fragLoc > -1) + { + fragment = spanified.Slice(fragLoc + 1); + spanified = spanified.Slice(0, fragLoc); + } var nextSlash = 0; actorPath = new RootActorPath(address); @@ -348,12 +357,11 @@ public static bool TryParse(string path, out ActorPath actorPath) spanified = spanified.Slice(nextSlash + 1); } while (nextSlash >= 0); - //var fragmentLocation = - //if (.StartsWith("#")) - //{ - // var uid = SpanHacks.Parse(uri.Fragment.AsSpan(1)); - // actorPath = actorPath.WithUid(uid); - //} + if (!fragment.IsEmpty) + { + var uid = SpanHacks.Parse(fragment); + actorPath = actorPath.WithUid(uid); + } return true; } @@ -392,7 +400,7 @@ private static bool TryParseAddress(string path, out Address address, out ReadOn return false; spanified = spanified.Slice(firstColonPos + 1); - if (!(spanified[0] == '/' && spanified[1] == '/')) + if (spanified.Length < 2 || !(spanified[0] == '/' && spanified[1] == '/')) return false; spanified = spanified.Slice(2); // move past the double //