Skip to content

Commit f3c2cd4

Browse files
committed
completed work on ActorPath parsing
1 parent e740424 commit f3c2cd4

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/core/Akka/Actor/ActorPath.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,15 @@ public static bool TryParse(string path, out ActorPath actorPath)
329329

330330
if (!TryParseAddress(path, out var address, out var absoluteUri)) return false;
331331
var spanified = absoluteUri;
332+
333+
// check for Uri fragment here
334+
var fragment = ReadOnlySpan<char>.Empty;
335+
var fragLoc = spanified.IndexOf('#');
336+
if (fragLoc > -1)
337+
{
338+
fragment = spanified.Slice(fragLoc + 1);
339+
spanified = spanified.Slice(0, fragLoc);
340+
}
332341
var nextSlash = 0;
333342

334343
actorPath = new RootActorPath(address);
@@ -348,12 +357,11 @@ public static bool TryParse(string path, out ActorPath actorPath)
348357
spanified = spanified.Slice(nextSlash + 1);
349358
} while (nextSlash >= 0);
350359

351-
//var fragmentLocation =
352-
//if (.StartsWith("#"))
353-
//{
354-
// var uid = SpanHacks.Parse(uri.Fragment.AsSpan(1));
355-
// actorPath = actorPath.WithUid(uid);
356-
//}
360+
if (!fragment.IsEmpty)
361+
{
362+
var uid = SpanHacks.Parse(fragment);
363+
actorPath = actorPath.WithUid(uid);
364+
}
357365
return true;
358366
}
359367

@@ -392,7 +400,7 @@ private static bool TryParseAddress(string path, out Address address, out ReadOn
392400
return false;
393401

394402
spanified = spanified.Slice(firstColonPos + 1);
395-
if (!(spanified[0] == '/' && spanified[1] == '/'))
403+
if (spanified.Length < 2 || !(spanified[0] == '/' && spanified[1] == '/'))
396404
return false;
397405

398406
spanified = spanified.Slice(2); // move past the double //

0 commit comments

Comments
 (0)