add invalid date test cases for address parsing functions

This commit is contained in:
Pierce 2023-08-12 17:45:40 -04:00
parent 1444d3dd57
commit 980fea6c8d
No known key found for this signature in database
GPG Key ID: EC79465B0E865E47
3 changed files with 11 additions and 8 deletions

View File

@ -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

View File

@ -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

View File

@ -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
},