This commit is contained in:
2021-08-09 19:49:44 +00:00
parent d16468d44b
commit e8426c1fcd
2 changed files with 24 additions and 7 deletions

View File

@@ -163,7 +163,7 @@ namespace AyaNova.PlugIn.V8
return;
}
ExportAssignedDocs = dOpt.ExportAssignedDocs;
ImportTag = dOpt.Tags;
ImportTag = Util.NormalizeTag(dOpt.Tags);
//here because we logged in fine and can proceed
//MessageBox.Show("Login successful! JWT is " + util.JWT);

View File

@@ -120,9 +120,9 @@ namespace AyaNova.PlugIn.V8
return false;
}
a = await GetAsync("server-state/");
ServerState = a.ObjectResponse["data"]["serverState"].Value<string>();
a = await GetAsync("server-state/");
ServerState = a.ObjectResponse["data"]["serverState"].Value<string>();
return true;
}
@@ -132,7 +132,7 @@ namespace AyaNova.PlugIn.V8
}
@@ -315,10 +315,12 @@ namespace AyaNova.PlugIn.V8
return Convert.ToBase64String(b);
}
public static string NormalizeTag(string inObj)
{
if (string.IsNullOrWhiteSpace(inObj)) return null;
//Must be lowercase per rules
//This may be naive when we get international customers but for now supporting utf-8 and it appears it's safe to do this with unicode
//This may be naive when we get international cust omers but for now supporting utf-8 and it appears it's safe to do this with unicode
inObj = inObj.ToLowerInvariant();
//No spaces in tags, replace with dashes
inObj = inObj.Replace(" ", "-");
@@ -327,10 +329,25 @@ namespace AyaNova.PlugIn.V8
//Ensure doesn't start or end with a dash
inObj = inObj.Trim('-');
//No longer than 255 characters
inObj = MaxLength(inObj, 255);
inObj = StringUtil.MaxLength(inObj, 255);
return inObj;
}
//clean up tags from client submission
//remove dupes, substitute dashes for spaces, lowercase and shorten if exceed 255 chars
//and sorts before returning to ensure consistent ordering
public static List<string> NormalizeTags(List<string> inTags)
{
if (inTags == null || inTags.Count == 0) return inTags;
List<string> outTags = new List<string>();
foreach (var tag in inTags)
outTags.Add(NormalizeTag(tag));
outTags.Sort();
return outTags.Distinct().ToList();
}
/// <summary>
/// Trim a string if necessary
/// </summary>