mirror of
https://github.com/CFC-Servers/cfc_cl_http_whitelist.git
synced 2025-03-04 03:03:18 -05:00
add invalid date test cases for address parsing functions
This commit is contained in:
parent
1444d3dd57
commit
980fea6c8d
@ -2,14 +2,12 @@ AddCSLuaFile()
|
||||
|
||||
---@alias WhitelistAddressOption { allowed: boolean|nil, noisy: boolean|nil, permanent: boolean|nil }
|
||||
|
||||
---@class WhitelistConfig
|
||||
---@class WhitelistConfig
|
||||
---@field version string
|
||||
---@field wrapHTMLPanels boolean|nil
|
||||
---@field defaultAssetURIOptions WhitelistAddressOption
|
||||
---@field defaultOptions WhitelistAddressOption
|
||||
---@field addresses table<string, WhitelistAddressOption>
|
||||
|
||||
---@type WhitelistConfig
|
||||
local config = {
|
||||
version = "1", -- this field allows backwards compatibility if the config structure is ever updated
|
||||
|
||||
|
@ -36,8 +36,9 @@ end
|
||||
|
||||
local parsedAddressCache = {}
|
||||
---@parm url string
|
||||
---@return string
|
||||
---@return string|nil
|
||||
function CFCHTTP.GetAddress( url )
|
||||
if not url then return end
|
||||
local cached = parsedAddressCache[url]
|
||||
if cached then return cached end
|
||||
|
||||
@ -50,4 +51,3 @@ end
|
||||
function CFCHTTP.IsAssetURI( url )
|
||||
return string.StartWith( url, "asset://" )
|
||||
end
|
||||
|
||||
|
@ -4,6 +4,8 @@ local testUrls = {
|
||||
{ url = "https://fox.pics:8080/0d875a97-2ab3-489c-b7db-d9d9f026504e.jpg", address = "fox.pics" },
|
||||
{ url = "https://cfcservers.org", address = "cfcservers.org" },
|
||||
{ url = "https://24.321.483.222", address = "24.321.483.222" },
|
||||
{ url = "nil", address = nil },
|
||||
{ url = nil, address = nil },
|
||||
}
|
||||
|
||||
local htmlBlobs = [[
|
||||
@ -28,9 +30,12 @@ return {
|
||||
for _, urlData in pairs( testUrls ) do
|
||||
local html = htmlBlobs:format( urlData.url )
|
||||
local urls = CFCHTTP.FileTypes.HTML.GetURLSFromData( html )
|
||||
|
||||
expect( #urls ).to.equal( 1 )
|
||||
expect( urls[1] ).to.equal( urlData.url )
|
||||
if urlData.address then
|
||||
expect( #urls ).to.equal( 1 )
|
||||
expect( urls[1] ).to.equal( urlData.url )
|
||||
else
|
||||
expect( #urls ).to.equal( 0 )
|
||||
end
|
||||
end
|
||||
end
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user