[PT Run] Folder path starting with backslash (#7711)

* folder plugin path starting with backslash

* handle single \ input
This commit is contained in:
Davide Giacometti 2020-11-03 10:36:16 +01:00 committed by GitHub
parent ccf02579e6
commit 6e8337c563
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
namespace Microsoft.Plugin.Folder.Sources
@ -78,6 +79,17 @@ namespace Microsoft.Plugin.Folder.Sources
public static string Expand(string search)
{
if (search == null)
{
throw new ArgumentNullException(nameof(search));
}
// Absolute path of system drive: \Windows\System32
if (search[0] == '\\' && (search.Length == 1 || search[1] != '\\'))
{
search = Path.Combine(Path.GetPathRoot(Environment.SystemDirectory), search.Substring(1));
}
return Environment.ExpandEnvironmentVariables(search);
}
}