Better globbing. Fix #12
This commit is contained in:
parent
be13234a43
commit
e9571b6427
@ -16,8 +16,11 @@ class AutoEntities extends cardTools.litElement() {
|
|||||||
match(pattern, str){
|
match(pattern, str){
|
||||||
if (typeof(str) === "string" && typeof(pattern) === "string") {
|
if (typeof(str) === "string" && typeof(pattern) === "string") {
|
||||||
if((pattern.startsWith('/') && pattern.endsWith('/')) || pattern.indexOf('*') !== -1) {
|
if((pattern.startsWith('/') && pattern.endsWith('/')) || pattern.indexOf('*') !== -1) {
|
||||||
if(pattern[0] !== '/')
|
if(pattern[0] !== '/') {
|
||||||
pattern = `/${pattern.replace(/\*/g, '.*')}/`;
|
pattern = pattern.replace(/\./g, '\.');
|
||||||
|
pattern = pattern.replace(/\*/g, '.*');
|
||||||
|
pattern = `/^${pattern}$/`;
|
||||||
|
}
|
||||||
var regex = new RegExp(pattern.substr(1).slice(0,-1));
|
var regex = new RegExp(pattern.substr(1).slice(0,-1));
|
||||||
return regex.test(str);
|
return regex.test(str);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user