aboutsummaryrefslogtreecommitdiffstats
path: root/lib/util.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-06-05 01:13:12 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-06-05 01:13:12 +0200
commit2b95e7ae6cb53f987931de8f567870b9e69cdf9a (patch)
tree9280099d9a70ea4f1c45734fe1b13944eb599f21 /lib/util.js
parent4f2e73837a000844c75bfa70d1be5debc0ac4859 (diff)
downloadbugzilla-triage-2b95e7ae6cb53f987931de8f567870b9e69cdf9a.tar.gz
Unfinished mess of everything, unworking.
Diffstat (limited to 'lib/util.js')
-rw-r--r--lib/util.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/util.js b/lib/util.js
index b6691af..3ce50c5 100644
--- a/lib/util.js
+++ b/lib/util.js
@@ -50,6 +50,28 @@ var isInList = exports.isInList = function isInList(mbr, list) {
};
/**
+ * select element of the array where regexp in the first element matches second
+ * parameter of this function
+ *
+ * @param list Array with regexps and return values
+ * @param chosingMark String by which the element of array is to be matched
+ * @return Object chosen element
+ */
+exports.filterByRegexp = function filterByRegexp(list, chosingMark) {
+ let chosenPair = [];
+ if (list.length > 0) {
+ chosenPair = list.filter(function(pair) {
+ return new RegExp(pair.regexp, "i").test(chosingMark);
+ });
+ }
+ if (chosenPair.length > 0) {
+ return chosenPair[0].addr;
+ } else {
+ return "";
+ }
+};
+
+/**
* format date to be in ISO format (just day part)
*
* @param date