Custom schemes '\' are now replaced with '/' on windows paths.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 24 Jul 2014 16:23:05 +0000 (17:23 +0100)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Thu, 24 Jul 2014 16:23:05 +0000 (17:23 +0100)
mcs/class/System/System/UriHelper.cs

index 640388ba8e8c82035d82911979fc3be0f180028c..28554870d5b4370aa8047ded6abcd94fc28d8229 100644 (file)
@@ -22,6 +22,7 @@ namespace System {
                        IPv6Host = 1 << 5,
                        NoSlashReplace = 1 << 6,
                        NoReduce = 1 << 7,
+                       HasWindowsPath = 1 << 8,
                }
 
                [Flags]
@@ -189,6 +190,11 @@ namespace System {
                                str.Length > 1 && str [0] == '[' && str [str.Length - 1] == ']')
                                 formatFlags |= UriHelper.FormatFlags.IPv6Host;
 
+                       if (component == UriComponents.Path &&
+                               str.Length >= 2 && str [1] != ':' &&
+                               ('a' <= str [0] && str [0] <= 'z') || ('A' <= str [0] && str [0] <= 'Z'))
+                               formatFlags |= UriHelper.FormatFlags.HasWindowsPath;
+
                        UriSchemes scheme = GetScheme (schemeName);
 
                        if (scheme == UriSchemes.Custom && (formatFlags & FormatFlags.HasHost) != 0)
@@ -284,6 +290,10 @@ namespace System {
 
                                if (SchemeContains (scheme, UriSchemes.NetPipe | UriSchemes.NetTcp | UriSchemes.File))
                                        return "/";
+
+                               if (SchemeContains (scheme, UriSchemes.Custom) &&
+                                       (formatFlags & FormatFlags.HasWindowsPath) == 0)
+                                       return "/";
                        }
 
                        var ret = c.ToString (CultureInfo.InvariantCulture);