Skip to content

Commit

Permalink
fix regex matching
Browse files Browse the repository at this point in the history
  • Loading branch information
vencax committed Feb 12, 2023
1 parent 433486f commit 1155d19
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions login_script.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ module.exports = (oauthProvider, message, content) => `
(function() {
function contains(arr, elem) {
for (var i = 0; i < arr.length; i++) {
if (arr[i] === elem) {
return true;
if (arr[i].indexOf('*') >= 0) {
const regex = new RegExp(arr[i].replaceAll('.', '\\\\.').replaceAll('*', '[\\\\w_-]+'))
console.log(regex)
if (elem.match(regex) !== null) {
return true;
}
} else {
if (arr[i] === elem) {
return true;
}
}
}
return false;
Expand Down

0 comments on commit 1155d19

Please sign in to comment.