[Modify] Polish it

master
sta 10 years ago
parent f4d88963f8
commit 01ad753c3a

@ -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;
}

Loading…
Cancel
Save