Add case for when user agent is nil
Add test for nil user agent
This commit is contained in:
parent
37c24b0df5
commit
b2beeeab25
2 changed files with 7 additions and 1 deletions
|
@ -1,4 +1,8 @@
|
||||||
describe("same_site_compatible_test", function()
|
describe("same_site_compatible_test", function()
|
||||||
|
it("returns true for nil user agent", function()
|
||||||
|
local same_site = require("util.same_site")
|
||||||
|
assert.True(same_site.same_site_none_compatible(nil))
|
||||||
|
end)
|
||||||
it("returns false for chrome 4", function()
|
it("returns false for chrome 4", function()
|
||||||
local same_site = require("util.same_site")
|
local same_site = require("util.same_site")
|
||||||
assert.False(same_site.same_site_none_compatible("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2704.103 Safari/537.36"))
|
assert.False(same_site.same_site_none_compatible("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2704.103 Safari/537.36"))
|
||||||
|
|
|
@ -13,7 +13,9 @@ local _M = {}
|
||||||
-- browsers which will reject SameSite=None cookies.
|
-- browsers which will reject SameSite=None cookies.
|
||||||
-- reference: https://www.chromium.org/updates/same-site/incompatible-clients
|
-- reference: https://www.chromium.org/updates/same-site/incompatible-clients
|
||||||
function _M.same_site_none_compatible(user_agent)
|
function _M.same_site_none_compatible(user_agent)
|
||||||
if string.match(user_agent, "Chrome/4") then
|
if not user_agent then
|
||||||
|
return true
|
||||||
|
elseif string.match(user_agent, "Chrome/4") then
|
||||||
return false
|
return false
|
||||||
elseif string.match(user_agent, "Chrome/5") then
|
elseif string.match(user_agent, "Chrome/5") then
|
||||||
return false
|
return false
|
||||||
|
|
Loading…
Reference in a new issue