From 0a742f2e917bef4f7f14b547901b3c13e636c84f Mon Sep 17 00:00:00 2001 From: sta Date: Tue, 12 Aug 2014 21:48:48 +0900 Subject: [PATCH] Refactored Ext.cs --- websocket-sharp/Ext.cs | 18 ++++++++---------- websocket-sharp/Net/Cookie.cs | 6 ++++-- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/websocket-sharp/Ext.cs b/websocket-sharp/Ext.cs index 7e39302e..e734b509 100644 --- a/websocket-sharp/Ext.cs +++ b/websocket-sharp/Ext.cs @@ -615,9 +615,7 @@ namespace WebSocketSharp internal static string Quote (this string value) { - return value.IsToken () - ? value - : String.Format ("\"{0}\"", value.Replace ("\"", "\\\"")); + return String.Format ("\"{0}\"", value.Replace ("\"", "\\\"")); } internal static byte[] ReadBytes (this Stream stream, int length) @@ -834,12 +832,12 @@ namespace WebSocketSharp /// A that represents the WebSocket URL to try. /// /// - /// When this method returns, a that represents the WebSocket URL if - /// is valid; otherwise, . + /// When this method returns, a that represents the WebSocket URL + /// if is valid; otherwise, . /// /// - /// When this method returns, a that represents the error message if - /// is invalid; otherwise, . + /// When this method returns, a that represents the error message + /// if is invalid; otherwise, . /// internal static bool TryCreateWebSocketUri ( this string uriString, out Uri result, out string message) @@ -880,9 +878,9 @@ namespace WebSocketSharp } } else { - uri = String.Format ( - "{0}://{1}:{2}{3}", schm, uri.Host, schm == "ws" ? 80 : 443, uri.PathAndQuery) - .ToUri (); + uri = new Uri ( + String.Format ( + "{0}://{1}:{2}{3}", schm, uri.Host, schm == "ws" ? 80 : 443, uri.PathAndQuery)); } result = uri; diff --git a/websocket-sharp/Net/Cookie.cs b/websocket-sharp/Net/Cookie.cs index b73a5cd6..aa6717dd 100644 --- a/websocket-sharp/Net/Cookie.cs +++ b/websocket-sharp/Net/Cookie.cs @@ -667,8 +667,10 @@ namespace WebSocketSharp.Net if (!_comment.IsNullOrEmpty ()) result.AppendFormat ("; Comment={0}", _comment.UrlEncode ()); - if (_commentUri != null) - result.AppendFormat ("; CommentURL={0}", _commentUri.OriginalString.Quote ()); + if (_commentUri != null) { + var url = _commentUri.OriginalString; + result.AppendFormat ("; CommentURL={0}", url.IsToken () ? url : url.Quote ()); + } if (_discard) result.Append ("; Discard");