Bläddra i källkod

fix: Fixes is_jibri check.

factor2
damencho 8 månader sedan
förälder
incheckning
aea9c5e79e
1 ändrade filer med 16 tillägg och 4 borttagningar
  1. 16
    4
      resources/prosody-plugins/util.lib.lua

+ 16
- 4
resources/prosody-plugins/util.lib.lua Visa fil

5
 local http = require "net.http";
5
 local http = require "net.http";
6
 local cache = require "util.cache";
6
 local cache = require "util.cache";
7
 local array = require "util.array";
7
 local array = require "util.array";
8
+local is_set = require 'util.set'.is_set;
8
 
9
 
9
 local http_timeout = 30;
10
 local http_timeout = 30;
10
 local have_async, async = pcall(require, "util.async");
11
 local have_async, async = pcall(require, "util.async");
288
 end
289
 end
289
 
290
 
290
 function starts_with_one_of(str, prefixes)
291
 function starts_with_one_of(str, prefixes)
291
-    if not str then
292
+    if not str or not prefixes then
292
         return false;
293
         return false;
293
     end
294
     end
294
-    for i=1,#prefixes do
295
-        if starts_with(str, prefixes[i]) then
296
-            return prefixes[i];
295
+
296
+    if is_set(prefixes) then
297
+        -- set is a table with keys and value of true
298
+        for k, _ in prefixes:items() do
299
+            if starts_with(str, k) then
300
+                return k;
301
+            end
302
+        end
303
+    else
304
+        for _, v in pairs(prefixes) do
305
+          if starts_with(str, v) then
306
+              return v;
307
+          end
297
         end
308
         end
298
     end
309
     end
310
+
299
     return false
311
     return false
300
 end
312
 end
301
 
313
 

Laddar…
Avbryt
Spara