Mercurial > prosody-modules
comparison mod_http_oauth2/mod_http_oauth2.lua @ 6276:e174e12549e1
mod_http_oauth2: Handle absent array argument in array member check
Allows this argument to be optional and prevents an error attempting to
obtain the length of nil.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Thu, 03 Jul 2025 12:27:32 +0200 |
| parents | ebcf612da2b1 |
| children | dfc035ecabb4 |
comparison
equal
deleted
inserted
replaced
| 6275:ebcf612da2b1 | 6276:e174e12549e1 |
|---|---|
| 27 return t[k]; | 27 return t[k]; |
| 28 end | 28 end |
| 29 end | 29 end |
| 30 | 30 |
| 31 local function array_contains(haystack, needle) | 31 local function array_contains(haystack, needle) |
| 32 if not haystack then | |
| 33 return false | |
| 34 end | |
| 32 for i = 1, #haystack do | 35 for i = 1, #haystack do |
| 33 if haystack[i] == needle then | 36 if haystack[i] == needle then |
| 34 return true | 37 return true |
| 35 end | 38 end |
| 36 end | 39 end |
