mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Make use of StringSplitOptions.TrimEntries when possible (#18412)
This commit is contained in:
@@ -1273,24 +1273,23 @@ namespace System.Management.Automation
|
||||
};
|
||||
|
||||
var modulePathList = new List<string>();
|
||||
foreach (var path in currentModulePath.Split(';'))
|
||||
foreach (var path in currentModulePath.Split(';', StringSplitOptions.TrimEntries))
|
||||
{
|
||||
var trimmedPath = path.Trim();
|
||||
if (!excludeModulePaths.Contains(trimmedPath))
|
||||
if (!excludeModulePaths.Contains(path))
|
||||
{
|
||||
// make sure this module path is Not part of other PS Core installation
|
||||
var possiblePwshDir = Path.GetDirectoryName(trimmedPath);
|
||||
var possiblePwshDir = Path.GetDirectoryName(path);
|
||||
|
||||
if (string.IsNullOrEmpty(possiblePwshDir))
|
||||
{
|
||||
// i.e. module dir is in the drive root
|
||||
modulePathList.Add(trimmedPath);
|
||||
modulePathList.Add(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!File.Exists(Path.Combine(possiblePwshDir, "pwsh.dll")))
|
||||
{
|
||||
modulePathList.Add(trimmedPath);
|
||||
modulePathList.Add(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user