This commit is contained in:
2020-10-08 14:30:24 +00:00
parent 0bf1386be3
commit 5895ff2a03
2 changed files with 46 additions and 2 deletions

View File

@@ -817,7 +817,7 @@ export default {
//that did NOT pass the truthy test function
//de-lodash
// let m = window.$gz._.remove(vm.formState.serverError.details, function(
// let m = window.$gz. _.remove(vm.formState.serverError.details, function(
// o
// ) {
// if (!o.target) {

View File

@@ -182,8 +182,42 @@ export default {
// Clean up a tag with same rules as server
//
normalizeTag: function(tagName) {
/*
SERVER VERSION
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 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(" ", "-");
//Remove multiple dash sequences
inObj = System.Text.RegularExpressions.Regex.Replace(inObj, "-+", "-");
//Ensure doesn't start or end with a dash
inObj = inObj.Trim('-');
//No longer than 255 characters
inObj = StringUtil.MaxLength(inObj, 255);
return inObj;
}
*/
//de-lodash
//kebab case takes care of all the things we need for tags in one go
tagName = window.$gz._.kebabCase(tagName);
// tagName = window.$gz._.kebabCase(tagName);
if (!tagName || tagName == "") {
return null;
}
tagName = tagName.toLowerCase();
//spaces to dashes
tagName = tagName.replace(/ /gi, "-");
//multiple dashes to single dashes
tagName = tagName.replace(/-+/g, "-");
//ensure doesn't start or end with a dash
tagName = this.trimSpecific(tagName, "-");
//No longer than 255 characters
tagName = tagName.length > 255 ? tagName.substr(0, 255 - 1) : tagName;
@@ -414,6 +448,16 @@ export default {
objectIsEmpty: function(obj) {
//https://stackoverflow.com/a/4994265/8939
return Object.keys(obj).length === 0;
},
///////////////////////////////////////////////
// Trim specific character from start and end
//
trimSpecific: function trim(str, ch) {
var start = 0,
end = str.length;
while (start < end && str[start] === ch) ++start;
while (end > start && str[end - 1] === ch) --end;
return start > 0 || end < str.length ? str.substring(start, end) : str;
}
/**