[Modify] Polish it

This commit is contained in:
sta 2017-01-24 16:54:39 +09:00
parent 57441de585
commit c70ec7f96d

View File

@ -926,35 +926,37 @@ namespace WebSocketSharp
/// or <see cref="String.Empty"/> if <paramref name="uriString"/> is valid. /// or <see cref="String.Empty"/> if <paramref name="uriString"/> is valid.
/// </param> /// </param>
internal static bool TryCreateWebSocketUri ( internal static bool TryCreateWebSocketUri (
this string uriString, out Uri result, out string message) this string uriString, out Uri result, out string message
)
{ {
result = null; result = null;
message = null;
var uri = uriString.ToUri (); var uri = uriString.ToUri ();
if (uri == null) { if (uri == null) {
message = "An invalid URI string: " + uriString; message = "An invalid URI string.";
return false; return false;
} }
if (!uri.IsAbsoluteUri) { if (!uri.IsAbsoluteUri) {
message = "Not an absolute URI: " + uriString; message = "Not an absolute URI.";
return false; return false;
} }
var schm = uri.Scheme; var schm = uri.Scheme;
if (!(schm == "ws" || schm == "wss")) { if (!(schm == "ws" || schm == "wss")) {
message = "The scheme part isn't 'ws' or 'wss': " + uriString; message = "The scheme part is not 'ws' or 'wss'.";
return false; return false;
} }
if (uri.Fragment.Length > 0) { if (uri.Fragment.Length > 0) {
message = "Includes the fragment component: " + uriString; message = "It includes the fragment component.";
return false; return false;
} }
var port = uri.Port; var port = uri.Port;
if (port == 0) { if (port == 0) {
message = "The port part is zero: " + uriString; message = "The port part is zero.";
return false; return false;
} }
@ -966,9 +968,10 @@ namespace WebSocketSharp
schm, schm,
uri.Host, uri.Host,
schm == "ws" ? 80 : 443, schm == "ws" ? 80 : 443,
uri.PathAndQuery)); uri.PathAndQuery
)
);
message = String.Empty;
return true; return true;
} }