pre-sort keys

This commit is contained in:
Fraser
2023-08-15 22:32:51 -04:00
parent 8d223e6ccd
commit 4fcc46dac1
+3 -1
View File
@@ -15,7 +15,9 @@ const MyApp: AppType = ({ Component, pageProps }) => {
.then((res) => res.json())
.then((data) => {
const glossary: Glossary = new Map(Object.entries(data));
const regex = new RegExp(Array.from(glossary.keys()).join("|"), "gim");
const keys = Array.from(glossary.keys()).sort((a, b) => b.length - a.length);
console.log(keys);
const regex = new RegExp(keys.join("|"), "gim");
setGlossary({ g: glossary, r: regex });
});
}, []);