[source:revert] remove support for alias arrays

May re-add in the future.
This commit is contained in:
Maddison Hellstrom 2020-11-18 16:52:44 -08:00
parent 4cae733ff4
commit 6464f04fed
2 changed files with 17 additions and 19 deletions

View File

@ -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),
},

32
util.js
View File

@ -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)
}
})))
}