REORG+histo
This commit is contained in:
33
src/isnd/Helpers/PackageIdHelpers.cs
Normal file
33
src/isnd/Helpers/PackageIdHelpers.cs
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
15
src/isnd/Helpers/PackageVersionHelpers.cs
Normal file
15
src/isnd/Helpers/PackageVersionHelpers.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
16
src/isnd/Helpers/ParamHelpers.cs
Normal file
16
src/isnd/Helpers/ParamHelpers.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user