From 6464f04fedb1a92936e8eceaeba086c2d50b167f Mon Sep 17 00:00:00 2001 From: Maddison Hellstrom Date: Wed, 18 Nov 2020 16:52:44 -0800 Subject: [PATCH] [source:revert] remove support for alias arrays May re-add in the future. --- keys.js | 4 ++-- util.js | 32 +++++++++++++++----------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/keys.js b/keys.js index 08fb244..9b04001 100644 --- a/keys.js +++ b/keys.js @@ -763,14 +763,14 @@ const maps = { { path: "/thermostat/DEVICE_.*", leader: "", - alias: ["+", "="], + alias: "=", description: "Increment temperature", callback: actions.nt.adjustTemp(1), }, { path: "/thermostat/DEVICE_.*", leader: "", - alias: ["-", "_"], + alias: "-", description: "Decrement temperature", callback: actions.nt.adjustTemp(-1), }, diff --git a/util.js b/util.js index c311616..effa57b 100644 --- a/util.js +++ b/util.js @@ -120,26 +120,24 @@ util.processMaps = (maps, aliases, siteleader) => { leader = (domain === "global") ? "" : siteleader, category = categories.misc, description = "", - path = "(/.*)?", - } = mapObj; - (Array.isArray(alias) ? alias : [alias]).forEach((a) => { - const opts = {} - const key = `${leader}${a}` + } = mapObj + const opts = {} - // Determine if it's a site-specific mapping - if (domain !== "global") { - const d = util.escapeRegExp(domain) - opts.domain = new RegExp(`^http(s)?://(([a-zA-Z0-9-_]+\\.)*)(${d})${path}`) - } + const key = `${leader}${alias}` - const fullDescription = `#${category} ${description}` + // Determine if it's a site-specific mapping + if (domain !== "global") { + const d = domain.replace(".", "\\.") + opts.domain = new RegExp(`^http(s)?://(([a-zA-Z0-9-_]+\\.)*)(${d})(/.*)?`) + } - if (mapObj.map !== undefined) { - map(a, mapObj.map) - } else { - mapkey(key, fullDescription, callback, opts) - } - }) + const fullDescription = `#${category} ${description}` + + if (mapObj.map !== undefined) { + map(alias, mapObj.map) + } else { + mapkey(key, fullDescription, callback, opts) + } }))) }