[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_.*", path: "/thermostat/DEVICE_.*",
leader: "", leader: "",
alias: ["+", "="], alias: "=",
description: "Increment temperature", description: "Increment temperature",
callback: actions.nt.adjustTemp(1), callback: actions.nt.adjustTemp(1),
}, },
{ {
path: "/thermostat/DEVICE_.*", path: "/thermostat/DEVICE_.*",
leader: "", leader: "",
alias: ["-", "_"], alias: "-",
description: "Decrement temperature", description: "Decrement temperature",
callback: actions.nt.adjustTemp(-1), callback: actions.nt.adjustTemp(-1),
}, },

32
util.js
View File

@ -120,26 +120,24 @@ util.processMaps = (maps, aliases, siteleader) => {
leader = (domain === "global") ? "" : siteleader, leader = (domain === "global") ? "" : siteleader,
category = categories.misc, category = categories.misc,
description = "", description = "",
path = "(/.*)?", } = mapObj
} = mapObj; const opts = {}
(Array.isArray(alias) ? alias : [alias]).forEach((a) => {
const opts = {}
const key = `${leader}${a}`
// Determine if it's a site-specific mapping const key = `${leader}${alias}`
if (domain !== "global") {
const d = util.escapeRegExp(domain)
opts.domain = new RegExp(`^http(s)?://(([a-zA-Z0-9-_]+\\.)*)(${d})${path}`)
}
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) { const fullDescription = `#${category} ${description}`
map(a, mapObj.map)
} else { if (mapObj.map !== undefined) {
mapkey(key, fullDescription, callback, opts) map(alias, mapObj.map)
} } else {
}) mapkey(key, fullDescription, callback, opts)
}
}))) })))
} }