Fix geo country cookie TypeError#706
Merged
Wituareard merged 2 commits intoPauseAI:mainfrom Mar 26, 2026
Merged
Conversation
geo.country is a Netlify Geo object {code, name}, not a string.
Using it directly as SetCookie value caused TypeError in production,
and the object-to-string comparison always evaluated to true,
resetting the cookie on every page load.
👷 Deploy request for pauseai pending review.Visit the deploys page to approve it
|
Collaborator
|
Thanks |
Collaborator
|
Thinking about whether we should check for |
Contributor
Author
|
Should be fine as-is. The cookie gets overwritten on the next visit when the value doesn't match: pauseai-website/src/routes/+layout.svelte Lines 44 to 52 in 05b157f |
Collaborator
|
Oh right, thanks for the clarification |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
geo.countryfrom Netlify's edge function context is an object{ code?: string; name?: string }, not a string. This caused two bugs introduced in #695:SetCookie'svaluecausedquote()to call.includes()on an object →TypeError: t.includes is not a functiontrue, so the cookie was re-set andselectBanners()was called on every page visitFix
Use
geo.country.code(the string country code) instead ofgeo.countryin both the comparison and the cookie value.Test plan
The geo API returns 501 in dev (no Netlify platform), so these can only be verified on a deploy preview:
TypeError: t.includes is not a functionin the consolegeo_countrycookie is set to a country code string (e.g."US"), not[object Object]