From 6d45d5ceca2852f95d47f4895504cb54c38fafef Mon Sep 17 00:00:00 2001 From: gravel Date: Wed, 20 Dec 2023 20:49:55 +0000 Subject: [PATCH] Fix partial room token matches in JS --- output/js/util.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/output/js/util.js b/output/js/util.js index 7cb8d0c6..74626df4 100644 --- a/output/js/util.js +++ b/output/js/util.js @@ -83,9 +83,17 @@ export const dom = { tbl_communities: () => document.getElementById("tbl_communities"), tbl_communities_content_rows: () => Array.from(dom.tbl_communities()?.rows)?.filter(row => !row.querySelector('th')), + /** + * @param {string} communityID + * @param {bool} matchIdPrefix + * @returns {HTMLRowElement | null} + */ community_row: (communityID, matchIdPrefix=false) => { const identifier = ATTRIBUTES.ROW.IDENTIFIER; + // Support matching shorter legacy IDs in links online const matches = matchIdPrefix ? '^=' : '='; + // Support matching room token, but only as a full match (plus symbol and hex code follows) + const id = communityID.includes('+') ? `${communityID}+` : communityID; return document.querySelector(`.room-row[${identifier}${matches}"${communityID}"]`); }, /**