From 3e45fef6c647f7fdc7d3f5c07b48b2e6e4056f87 Mon Sep 17 00:00:00 2001 From: nosami Date: Thu, 9 Jun 2022 23:18:38 +0100 Subject: Simplify uri -> filename conversion --- Mono.Debugging/Mono.Debugging.Client/SourceLink.cs | 25 +--------------------- 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/Mono.Debugging/Mono.Debugging.Client/SourceLink.cs b/Mono.Debugging/Mono.Debugging.Client/SourceLink.cs index 9c78393..56cde15 100644 --- a/Mono.Debugging/Mono.Debugging.Client/SourceLink.cs +++ b/Mono.Debugging/Mono.Debugging.Client/SourceLink.cs @@ -1,17 +1,11 @@ using System; -using System.Collections.Generic; using System.IO; -using System.Linq; -using System.Text; namespace Mono.Debugging.Client { [Serializable] public class SourceLink { - // Keep the / character to use as a path separator to help group related symbols - static readonly HashSet invalids = new HashSet(Path.GetInvalidFileNameChars ().Except (new char[] { '/' })); - public string Uri { get; } public string RelativeFilePath { get; } @@ -25,24 +19,7 @@ namespace Mono.Debugging.Client public string GetDownloadLocation (string cachePath) { var uri = new Uri (Uri); - return Path.Combine (cachePath, MakeValidFileName (uri)); - } - - static string MakeValidFileName (Uri uri) - { - // Remove scheme from uri - var text = uri.Host + uri.PathAndQuery; - var sb = new StringBuilder (text.Length); - for (int i = 0; i < text.Length; i++) { - char c = text[i]; - if (invalids.Contains (c)) { - sb.Append ('_'); - } else - sb.Append (c); - } - if (sb.Length == 0) - return "_"; - return sb.ToString (); + return Path.Combine (cachePath, uri.Host + uri.PathAndQuery); } } } -- cgit v1.2.3