Software /
code /
prosody-modules
Comparison
mod_block_registrations/mod_block_registrations.lua @ 1697:27aa58ed3e2e
mod_block_registrations: string.find is faster than string.match when only needing a boolean answer
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 05 May 2015 15:31:11 +0200 |
parent | 1331:dbaa67babeb4 |
child | 5065:368bf9b06484 |
comparison
equal
deleted
inserted
replaced
1696:efc1d674eac0 | 1697:27aa58ed3e2e |
---|---|
8 function is_blocked(username) | 8 function is_blocked(username) |
9 -- Check if the username is simply blocked | 9 -- Check if the username is simply blocked |
10 if block_users:contains(username) then return true; end | 10 if block_users:contains(username) then return true; end |
11 | 11 |
12 for pattern in block_patterns do | 12 for pattern in block_patterns do |
13 if username:match(pattern) then | 13 if username:find(pattern) then |
14 return true; | 14 return true; |
15 end | 15 end |
16 end | 16 end |
17 -- Not blocked, but check that username matches allowed pattern | 17 -- Not blocked, but check that username matches allowed pattern |
18 if require_pattern and not username:match(require_pattern) then | 18 if require_pattern and not username:match(require_pattern) then |