Skip to content

Commit

Permalink
completed work on ActorPath parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed May 28, 2021
1 parent e740424 commit f3c2cd4
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/core/Akka/Actor/ActorPath.cs
Expand Up @@ -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<char>.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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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 //
Expand Down

0 comments on commit f3c2cd4

Please sign in to comment.