mirror of
https://github.com/wassname/stampy-chat.git
synced 2026-09-10 12:40:44 +08:00
pre-sort keys
This commit is contained in:
@@ -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 });
|
||||
});
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user