[Modify] Polish it

This commit is contained in:
sta 2021-09-23 19:31:52 +09:00
parent 21b16251c7
commit 8becafea92

View File

@ -963,17 +963,21 @@ namespace WebSocketSharp.Server
if (path.Length == 0) if (path.Length == 0)
throw new ArgumentException ("An empty string.", "path"); throw new ArgumentException ("An empty string.", "path");
if (path[0] != '/') if (path[0] != '/') {
throw new ArgumentException ("Not an absolute path.", "path"); var msg = "It is not an absolute path.";
throw new ArgumentException (msg, "path");
}
if (path.IndexOfAny (new[] { '?', '#' }) > -1) { if (path.IndexOfAny (new[] { '?', '#' }) > -1) {
var msg = "It includes either or both query and fragment components."; var msg = "It includes either or both query and fragment components.";
throw new ArgumentException (msg, "path"); throw new ArgumentException (msg, "path");
} }
path = path.TrimSlashFromEnd (); path = path.TrimSlashFromEnd ();
WebSocketServiceHost host; WebSocketServiceHost host;
lock (_sync) { lock (_sync) {
if (!_hosts.TryGetValue (path, out host)) if (!_hosts.TryGetValue (path, out host))
return false; return false;