From baddd89abb78fa458226f6099ef81f051b7d21fc Mon Sep 17 00:00:00 2001 From: jed Date: Sun, 21 Oct 2018 17:58:41 +0200 Subject: [PATCH] Added flag to $tw.utils.parseStringArray to allow non-unique entries (#2027) * Added flag to $tw.utils.parseStringArray to allow non-unique entries With this change if you use $tw.utils.parseStringArray(list) you get identical behavior to before and enforces uniqueness in lists, but if you use $tw.utils.parseStringArray(list,true) it allows duplicate values in the list. Because of how JavaScript handles overloaded functions this shouldn't have any affect on existing code that just passes one argument to the function. * Update to hopefully remove merge conflicts --- boot/boot.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index e5b608cae..ef1e9e86b 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -268,7 +268,7 @@ $tw.utils.stringifyList = function(value) { }; // Parse a string array from a bracketted list. For example "OneTiddler [[Another Tiddler]] LastOne" -$tw.utils.parseStringArray = function(value) { +$tw.utils.parseStringArray = function(value, allowDuplicate) { if(typeof value === "string") { var memberRegExp = /(?:^|[^\S\xA0])(?:\[\[(.*?)\]\])(?=[^\S\xA0]|$)|([\S\xA0]+)/mg, results = [], names = {}, @@ -277,7 +277,7 @@ $tw.utils.parseStringArray = function(value) { match = memberRegExp.exec(value); if(match) { var item = match[1] || match[2]; - if(item !== undefined && !$tw.utils.hop(names,item)) { + if(item !== undefined && (!$tw.utils.hop(names,item) || allowDuplicate)) { results.push(item); names[item] = true; }