Skip to content

Commit

Permalink
Use "get" instead of "has" for checking searchParams (#2113)
Browse files Browse the repository at this point in the history
Fix #2072

Not all implementations of JS have the `has(name, value)` syntax
  • Loading branch information
KyleAMathews authored and msfstef committed Dec 9, 2024
1 parent 4c7fb72 commit 303b191
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions .changeset/modern-poets-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@electric-sql/client": patch
---

Use "get" instead of "has" for checking searchParams

Not all implementations of JS have the has(name, value) syntax e.g. Expo.
4 changes: 2 additions & 2 deletions packages/typescript-client/src/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ export function createFetchWithResponseHeadersCheck(
const input = args[0]
const urlString = input.toString()
const url = new URL(urlString)
if (url.searchParams.has(LIVE_QUERY_PARAM, `true`)) {
if (url.searchParams.get(LIVE_QUERY_PARAM) === `true`) {
addMissingHeaders(requiredLiveResponseHeaders)
}

if (
!url.searchParams.has(LIVE_QUERY_PARAM) ||
url.searchParams.has(LIVE_QUERY_PARAM, `false`)
url.searchParams.get(LIVE_QUERY_PARAM) === `false`
) {
addMissingHeaders(requiredNonLiveResponseHeaders)
}
Expand Down

0 comments on commit 303b191

Please sign in to comment.