ti2-bokun 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,16 @@
1
+ const wildcardMatch = (str, wildcard) => {
2
+ if (!str || !wildcard) return false;
3
+
4
+ // eslint-disable-next-line no-useless-escape -- [ and / escaped for regex char class clarity
5
+ const escapeRegex = s => s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, '\\$1');
6
+
7
+ const pattern = wildcard
8
+ .split('*')
9
+ .map(escapeRegex)
10
+ .join('.*');
11
+
12
+ const regex = new RegExp(`^${pattern}$`, 'i');
13
+ return regex.test(str);
14
+ };
15
+
16
+ module.exports = wildcardMatch;