diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index be4bfe36..e37c5d8f 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -4,7 +4,7 @@ * * Some parts of this code are derived from Mono (http://www.mono-project.com): * - GetStatusDescription is derived from HttpListenerResponse.cs (System.Net) - * - IsPredefinedScheme is derived from Uri.cs (System) + * - isPredefinedScheme is derived from Uri.cs (System) * - MaybeUri is derived from Uri.cs (System) * * The MIT License @@ -160,6 +160,39 @@ namespace WebSocketSharp || value == "POST"; } + private static bool isPredefinedScheme (this string value) + { + if (value.Length < 2) + return false; + + var c = value[0]; + + if (c == 'h') + return value == "http" || value == "https"; + + if (c == 'w') + return value == "ws" || value == "wss"; + + if (c == 'f') + return value == "file" || value == "ftp"; + + if (c == 'g') + return value == "gopher"; + + if (c == 'm') + return value == "mailto"; + + if (c == 'n') { + c = value[1]; + + return c == 'e' + ? value == "news" || value == "net.pipe" || value == "net.tcp" + : value == "nntp"; + } + + return false; + } + #endregion #region Internal Methods @@ -1524,49 +1557,6 @@ namespace WebSocketSharp return value == null || value.Length == 0; } - /// - /// Determines whether the specified string is a predefined scheme. - /// - /// - /// true if is a predefined scheme; - /// otherwise, false. - /// - /// - /// A to test. - /// - public static bool IsPredefinedScheme (this string value) - { - if (value == null || value.Length < 2) - return false; - - var c = value[0]; - - if (c == 'h') - return value == "http" || value == "https"; - - if (c == 'w') - return value == "ws" || value == "wss"; - - if (c == 'f') - return value == "file" || value == "ftp"; - - if (c == 'g') - return value == "gopher"; - - if (c == 'm') - return value == "mailto"; - - if (c == 'n') { - c = value[1]; - - return c == 'e' - ? value == "news" || value == "net.pipe" || value == "net.tcp" - : value == "nntp"; - } - - return false; - } - /// /// Determines whether the specified string is a URI string. /// @@ -1595,7 +1585,7 @@ namespace WebSocketSharp var schm = value.Substring (0, idx); - return schm.IsPredefinedScheme (); + return schm.isPredefinedScheme (); } ///