Skip to content
This repository was archived by the owner on Apr 28, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ if IsDuplicityVersion() then
["burger", 1, 1]
]
]])),
validhosts = json.decode(GetConvar('inventory:validhosts', [[
{
"r2.fivemanage.com": true,
"i.fmfile.com": true
}
]])),
}

local accounts = json.decode(GetConvar('inventory:accounts', '["money"]'))
Expand Down
28 changes: 22 additions & 6 deletions modules/utils/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ local Utils = {}
local webHook = GetConvar('inventory:webhook', '')

if webHook ~= '' then
local validHosts = {
['i.imgur.com'] = true,
}

local validExtensions = {
['png'] = true,
['apng'] = true,
Expand All @@ -18,8 +14,28 @@ if webHook ~= '' then
local headers = { ['Content-Type'] = 'application/json' }

function Utils.IsValidImageUrl(url)
local host, extension = url:match('^https?://([^/]+).+%.([%l]+)')
return host and extension and validHosts[host] and validExtensions[extension]
local isUri = url:match("^nui://.+")
if isUri then
local resource, extension = url:match('^nui://([^/]+)/.-%.(%l+)$')

if not resource or not extension then return false end

local resourceState = GetResourceState(resource)
if resourceState ~= 'started' then return false end

return validExtensions[extension]
end

local isUrl = url:match("^https?://.+")
if isUrl then
local host, extension = url:match('^https?://([^/]+).+%.([%l]+)')

if not host or not extension then return false end

return server.validhosts[host] and validExtensions[extension]
end

return false
end

---@param title string
Expand Down