[Modify] Polish it

This commit is contained in:
sta 2016-06-03 16:52:36 +09:00
parent f4d88963f8
commit 01ad753c3a

View File

@ -216,21 +216,26 @@ namespace WebSocketSharp.Net
}
private static HttpListener matchFromList (
string host, string path, List<HttpListenerPrefix> list, out HttpListenerPrefix prefix)
string host, string path, List<HttpListenerPrefix> list, out HttpListenerPrefix prefix
)
{
prefix = null;
if (list == null)
return null;
HttpListener bestMatch = null;
var bestLen = -1;
foreach (var pref in list) {
var ppath = pref.Path;
if (ppath.Length < bestLen)
var prefPath = pref.Path;
var len = prefPath.Length;
if (len < bestLen)
continue;
if (path.StartsWith (ppath)) {
bestLen = ppath.Length;
if (path.StartsWith (prefPath)) {
bestLen = len;
bestMatch = pref.Listener;
prefix = pref;
}