Missed one empty case in GetPathRoot (#12883)
authorJeremy Kuhne <jeremy.kuhne@microsoft.com>
Tue, 18 Jul 2017 22:51:21 +0000 (15:51 -0700)
committerGitHub <noreply@github.com>
Tue, 18 Jul 2017 22:51:21 +0000 (15:51 -0700)
This matches our new behavior with whitespace paths

src/mscorlib/shared/System/IO/Path.Windows.cs
src/mscorlib/shared/System/IO/Path.cs

index 4397171..3732347 100644 (file)
@@ -141,7 +141,7 @@ namespace System.IO
         public static string GetPathRoot(string path)
         {
             if (path == null) return null;
-            if (string.IsNullOrEmpty(path))
+            if (PathInternal.IsEffectivelyEmpty(path))
                 throw new ArgumentException(SR.Arg_PathEmpty, nameof(path));
 
             PathInternal.CheckInvalidPathChars(path);
index aa7c5cd..135bb42 100644 (file)
@@ -76,11 +76,11 @@ namespace System.IO
         // "\\server\share").
         public static string GetDirectoryName(string path)
         {
+            if (path == null)
+                return null;
+
             if (PathInternal.IsEffectivelyEmpty(path))
-            {
-                if (path == null) return null;
                 throw new ArgumentException(SR.Arg_PathEmpty, nameof(path));
-            }
 
             PathInternal.CheckInvalidPathChars(path);
             path = PathInternal.NormalizeDirectorySeparators(path);