Improve path/uri handling (#82)
* Improve file path special characters handling * More specific tests * Optimize EnhancedStackTrace.TryGetFullPath to prevent exceptions being thrown and the immediately re-caught
This commit is contained in:
committed by
Ben Adams
parent
9b85871130
commit
8604340a0e
@@ -129,18 +129,10 @@ namespace System.Diagnostics
|
||||
/// </summary>
|
||||
public static string TryGetFullPath(string filePath)
|
||||
{
|
||||
try
|
||||
if (Uri.TryCreate(filePath, UriKind.Absolute, out var uri) && uri.IsFile)
|
||||
{
|
||||
var uri = new Uri(filePath);
|
||||
if (uri.IsFile)
|
||||
{
|
||||
return uri.AbsolutePath;
|
||||
}
|
||||
|
||||
return uri.ToString();
|
||||
return Uri.UnescapeDataString(uri.AbsolutePath);
|
||||
}
|
||||
catch (ArgumentException) { }
|
||||
catch (UriFormatException) { }
|
||||
|
||||
return filePath;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user