Skip to content

Commit

Permalink
Merge pull request #102 from The-FSB-Companies/master
Browse files Browse the repository at this point in the history
Permanent fix for React Native / IE encoding bug
  • Loading branch information
richmolj authored Oct 11, 2021
2 parents 45dc81f + 7e25594 commit fe32094
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Spraypaint

JS Client for [Graphiti](https://graphiti-api.github.io/graphiti) similar to ActiveRecord.
A fork of the JS Client for [Graphiti](https://graphiti-api.github.io/graphiti), made compatible with React-Native.
This repository will be deleted if the compatibility-focused changes are merged into the main project.

Written in [Typescript](https://www.typescriptlang.org) but works in plain old ES5 as well. This library is isomorphic - use it from the browser, or from the server with NodeJS.

Expand Down Expand Up @@ -49,4 +50,4 @@ let names = data.map((p) => { return p.fullName })
console.log(names) // ['Joe Blow', 'Joe DiMaggio', ...]

console.log(data[0].pets[0].name) // "Fido"
```
```
4 changes: 3 additions & 1 deletion src/util/parameterize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ const parameterize = (obj: any, prefix?: string): string => {

// IE does not encode by default like other browsers
const maybeEncode = (value: string): string => {
const isBrowser = typeof window !== "undefined"
var isBrowser =
typeof window !== "undefined" &&
typeof window.navigator.userAgent !== "undefined"
const isIE = isBrowser && window.navigator.userAgent.match(/(MSIE|Trident)/)
const isEncoded = typeof value === "string" && value.indexOf("%") !== -1
const shouldEncode = isBrowser && isIE && !isEncoded
Expand Down

0 comments on commit fe32094

Please sign in to comment.