REORG+histo

This commit is contained in:
2021-09-05 15:44:47 +01:00
parent 459f8ea422
commit 6dd76ac1a5
28 changed files with 948 additions and 159 deletions

View File

@ -0,0 +1,33 @@
namespace isnd.Helpers
{
public static class PackageIdHelpers
{
internal static bool SeparatedByMinusMatch(string id, string q)
{
foreach (var part in id.Split('-'))
{
if (part.StartsWith(q, System.StringComparison.OrdinalIgnoreCase)) return true;
}
return false;
}
internal static bool CamelCaseMatch(string id, string query)
{
// Assert.False (q==null);
if (string.IsNullOrEmpty(query)) return true;
while (id.Length > 0)
{
int i = 0;
while (id.Length > i && char.IsLower(id[i])) i++;
if (i == 0) break;
id = id.Substring(i);
if (id.StartsWith(query, System.StringComparison.OrdinalIgnoreCase)) return true;
}
return false;
}
}
}

View File

@ -0,0 +1,15 @@
using System.Security.Claims;
using isnd.Data;
namespace isnd.Helpers
{
public static class PackageVersionHelpers
{
public static bool IsOwner(this ClaimsPrincipal user, PackageVersion v)
{
var userId = user.FindFirstValue(ClaimTypes.NameIdentifier);
return v.Package.OwnerId == userId;
}
}
}

View File

@ -0,0 +1,16 @@
namespace isnd.Helpers
{
public static class ParamHelpers
{
public static string Optional(ref string prm)
{
int sopt = prm.IndexOf('/');
if (sopt>0)
{
prm = prm.Substring(0,sopt);
return prm.Substring(sopt + 1);
}
return null;
}
}
}