From f0231b87dc5d06933876be2f57fa0b27753c355b Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Mon, 20 Sep 2021 21:53:58 -0500 Subject: trim trailing slashes from root paths --- src/slskd/Application/SharedFileCache.cs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/slskd/Application/SharedFileCache.cs') diff --git a/src/slskd/Application/SharedFileCache.cs b/src/slskd/Application/SharedFileCache.cs index 7bd30d2a..52c75ed1 100644 --- a/src/slskd/Application/SharedFileCache.cs +++ b/src/slskd/Application/SharedFileCache.cs @@ -406,11 +406,13 @@ namespace slskd LocalPath = share; } - Mask = Compute.MaskHash(System.IO.Directory.GetParent(LocalPath).FullName); + var parent = System.IO.Directory.GetParent(LocalPath).FullName.TrimEnd('/', '\\'); - var maskedPath = LocalPath.ReplaceFirst(System.IO.Directory.GetParent(LocalPath).FullName, Mask); + Mask = Compute.MaskHash(parent); - var aliasedSegment = LocalPath[(System.IO.Directory.GetParent(LocalPath).FullName.Length + 1)..]; + var maskedPath = LocalPath.ReplaceFirst(parent, Mask); + + var aliasedSegment = LocalPath[(parent.Length + 1)..]; RemotePath = maskedPath.ReplaceFirst(aliasedSegment, Alias); } -- cgit v1.2.3