From e9571b6427ad3fb276dc3c7fa3e8684f4d756f13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Lov=C3=A9n?= Date: Wed, 20 Mar 2019 08:41:01 +0100 Subject: [PATCH] Better globbing. Fix #12 --- auto-entities.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/auto-entities.js b/auto-entities.js index deaabe1..a878666 100644 --- a/auto-entities.js +++ b/auto-entities.js @@ -16,8 +16,11 @@ class AutoEntities extends cardTools.litElement() { match(pattern, str){ if (typeof(str) === "string" && typeof(pattern) === "string") { if((pattern.startsWith('/') && pattern.endsWith('/')) || pattern.indexOf('*') !== -1) { - if(pattern[0] !== '/') - pattern = `/${pattern.replace(/\*/g, '.*')}/`; + if(pattern[0] !== '/') { + pattern = pattern.replace(/\./g, '\.'); + pattern = pattern.replace(/\*/g, '.*'); + pattern = `/^${pattern}$/`; + } var regex = new RegExp(pattern.substr(1).slice(0,-1)); return regex.test(str); }