Skip to content

Commit

Permalink
chore(utils): remove unused utils
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Oct 19, 2024
1 parent 8551154 commit b36715d
Showing 1 changed file with 0 additions and 48 deletions.
48 changes: 0 additions & 48 deletions src/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ function utils.hasMatchingTag(tag, value)
return Handlers.utils.hasMatchingTag(tag, value)
end

function utils.reply(msg)
Handlers.utils.reply(msg)
end

-- Then, check for a 43-character base64url pattern.
-- The pattern checks for a string of length 43 containing alphanumeric characters, hyphens, or underscores.
function utils.isValidBase64Url(url)
Expand Down Expand Up @@ -197,42 +193,6 @@ function utils.safeDecodeJson(jsonString)
return result
end

function utils.validateFQDN(fqdn)
-- Check if the fqdn is not nil and not empty
if not fqdn or fqdn == "" then
error("FQDN is empty")
end

-- Split the fqdn into parts by dot and validate each part
local parts = {}
for part in fqdn:gmatch("[^%.]+") do
table.insert(parts, part)
end

-- Validate each part of the domain
for _, part in ipairs(parts) do
-- Check that the part length is between 1 and 63 characters
if #part < 1 or #part > 63 then
error("Invalid fqdn format: each part must be between 1 and 63 characters")
end
-- Check that the part does not start or end with a hyphen
if part:match("^-") or part:match("-$") then
error("Invalid fqdn format: parts must not start or end with a hyphen")
end
-- Check that the part contains only alphanumeric characters and hyphen
if not part:match("^[A-Za-z0-9-]+$") then
error("Invalid fqdn format: parts must contain only alphanumeric characters or hyphen")
end
end

-- Check if there is at least one top-level domain (TLD)
if #parts < 2 then
error("Invalid fqdn format: missing top-level domain")
end

return fqdn
end

function utils.findInArray(array, predicate)
for i = 1, #array do
if predicate(array[i]) then
Expand All @@ -246,14 +206,6 @@ function utils.walletHasSufficientBalance(wallet, quantity)
return Balances[wallet] ~= nil and Balances[wallet] >= quantity
end

function utils.copyTable(table)
local copy = {}
for key, value in pairs(table) do
copy[key] = value
end
return copy
end

function utils.deepCopy(original)
if not original then
return nil
Expand Down

0 comments on commit b36715d

Please sign in to comment.