comparison mod_bob/mod_bob.lua @ 3343:2e65160187a4

mod_bob: Simplify check_cid using string.match. (thanks Zash!)
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Fri, 28 Sep 2018 16:31:36 +0200
parents 3aa5419e3576
children 76fc915647ab
comparison
equal deleted inserted replaced
3342:3aa5419e3576 3343:2e65160187a4
10 local cache = {}; 10 local cache = {};
11 -- TODO: use util.cache for this. 11 -- TODO: use util.cache for this.
12 local in_flight = {}; 12 local in_flight = {};
13 13
14 local function check_cid(src) 14 local function check_cid(src)
15 -- TODO: figure out why ^ can’t be used at the beginning of the pattern. 15 return src:match("^cid:(%w+%+%w+@bob%.xmpp%.org)$");
16 for cid in src:gmatch("cid:(%w+%+%w+@bob%.xmpp%.org)$") do
17 return cid;
18 end
19 return nil;
20 end 16 end
21 17
22 local function handle_data_carrier(tag) 18 local function handle_data_carrier(tag)
23 if tag.name ~= "data" or tag.attr.xmlns ~= "urn:xmpp:bob" then 19 if tag.name ~= "data" or tag.attr.xmlns ~= "urn:xmpp:bob" then
24 return tag; 20 return tag;