mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
update url matching
This commit is contained in:
parent
ef94bab432
commit
598f1cf2bd
@ -109,7 +109,7 @@ namespace ServiceStack.Host
|
|||||||
this.Notes = notes;
|
this.Notes = notes;
|
||||||
this.restPath = path;
|
this.restPath = path;
|
||||||
|
|
||||||
this.allowsAllVerbs = verbs == null || verbs == WildCard;
|
this.allowsAllVerbs = verbs == null || string.Equals(verbs, WildCard, StringComparison.OrdinalIgnoreCase);
|
||||||
if (!this.allowsAllVerbs)
|
if (!this.allowsAllVerbs)
|
||||||
{
|
{
|
||||||
this.allowedVerbs = verbs.ToUpper();
|
this.allowedVerbs = verbs.ToUpper();
|
||||||
@ -123,7 +123,7 @@ namespace ServiceStack.Host
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(component)) continue;
|
if (string.IsNullOrEmpty(component)) continue;
|
||||||
|
|
||||||
if (component.Contains(VariablePrefix)
|
if (StringContains(component, VariablePrefix)
|
||||||
&& component.IndexOf(ComponentSeperator) != -1)
|
&& component.IndexOf(ComponentSeperator) != -1)
|
||||||
{
|
{
|
||||||
hasSeparators.Add(true);
|
hasSeparators.Add(true);
|
||||||
@ -240,12 +240,17 @@ namespace ServiceStack.Host
|
|||||||
score += Math.Max((10 - VariableArgsCount), 1) * 100;
|
score += Math.Max((10 - VariableArgsCount), 1) * 100;
|
||||||
|
|
||||||
//Exact verb match is better than ANY
|
//Exact verb match is better than ANY
|
||||||
var exactVerb = httpMethod == AllowedVerbs;
|
var exactVerb = string.Equals(httpMethod, AllowedVerbs, StringComparison.OrdinalIgnoreCase);
|
||||||
score += exactVerb ? 10 : 1;
|
score += exactVerb ? 10 : 1;
|
||||||
|
|
||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool StringContains(string str1, string str2)
|
||||||
|
{
|
||||||
|
return str1.IndexOf(str2, StringComparison.OrdinalIgnoreCase) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// For performance withPathInfoParts should already be a lower case string
|
/// For performance withPathInfoParts should already be a lower case string
|
||||||
/// to minimize redundant matching operations.
|
/// to minimize redundant matching operations.
|
||||||
@ -259,7 +264,7 @@ namespace ServiceStack.Host
|
|||||||
wildcardMatchCount = 0;
|
wildcardMatchCount = 0;
|
||||||
|
|
||||||
if (withPathInfoParts.Length != this.PathComponentsCount && !this.IsWildCardPath) return false;
|
if (withPathInfoParts.Length != this.PathComponentsCount && !this.IsWildCardPath) return false;
|
||||||
if (!this.allowsAllVerbs && !this.allowedVerbs.Contains(httpMethod.ToUpper())) return false;
|
if (!this.allowsAllVerbs && !StringContains(this.allowedVerbs, httpMethod)) return false;
|
||||||
|
|
||||||
if (!ExplodeComponents(ref withPathInfoParts)) return false;
|
if (!ExplodeComponents(ref withPathInfoParts)) return false;
|
||||||
if (this.TotalComponentsCount != withPathInfoParts.Length && !this.IsWildCardPath) return false;
|
if (this.TotalComponentsCount != withPathInfoParts.Length && !this.IsWildCardPath) return false;
|
||||||
|
@ -83,7 +83,7 @@ namespace ServiceStack.Host
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public readonly Dictionary<string, List<RestPath>> RestPathMap = new Dictionary<string, List<RestPath>>();
|
public readonly Dictionary<string, List<RestPath>> RestPathMap = new Dictionary<string, List<RestPath>>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
public void RegisterRestPaths(Type requestType)
|
public void RegisterRestPaths(Type requestType)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user