[Modify] Polish it
This commit is contained in:
parent
f4d88963f8
commit
01ad753c3a
@ -216,21 +216,26 @@ namespace WebSocketSharp.Net
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static HttpListener matchFromList (
|
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;
|
prefix = null;
|
||||||
|
|
||||||
if (list == null)
|
if (list == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
HttpListener bestMatch = null;
|
HttpListener bestMatch = null;
|
||||||
|
|
||||||
var bestLen = -1;
|
var bestLen = -1;
|
||||||
foreach (var pref in list) {
|
foreach (var pref in list) {
|
||||||
var ppath = pref.Path;
|
var prefPath = pref.Path;
|
||||||
if (ppath.Length < bestLen)
|
|
||||||
|
var len = prefPath.Length;
|
||||||
|
if (len < bestLen)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (path.StartsWith (ppath)) {
|
if (path.StartsWith (prefPath)) {
|
||||||
bestLen = ppath.Length;
|
bestLen = len;
|
||||||
bestMatch = pref.Listener;
|
bestMatch = pref.Listener;
|
||||||
prefix = pref;
|
prefix = pref;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user