Skip to content

Commit

Permalink
Better globbing. Fix #12
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasloven committed Mar 20, 2019
1 parent be13234 commit e9571b6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions auto-entities.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit e9571b6

Please sign in to comment.