Skip to content

Commit

Permalink
fix: change btoa func to encodeURI
Browse files Browse the repository at this point in the history
  • Loading branch information
echoxyc committed Nov 17, 2022
1 parent 19babc6 commit 4be4db4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const Evaluate: FC<{ type: string; data?: any }> = (props) => {

const handleTernCompletions = (data: TypeQueryResult): TransQuery => {
const result: TransQuery = data ?? {}
const doc = atob(data?.doc ?? "")
const doc = decodeURI(data?.doc ?? "")
if (doc?.slice(0, 1) === "{") {
const format = JSON.parse(doc)
result["data"] = format.data
Expand Down
10 changes: 7 additions & 3 deletions apps/builder/src/components/CodeEditor/TernSever/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const transDataToDefs = (
const def: Record<string, any> = {}
if (current) {
path = path ? path + "." + current : current
def["!doc"] = btoa(JSON.stringify({ path, data }))
def["!doc"] = encodeURI(JSON.stringify({ path, data }))
}
for (const dataKey in data) {
let newPath = path ? path + "." + dataKey : dataKey
Expand All @@ -84,12 +84,16 @@ const transDataToDefs = (
def[dataKey] = {
...d,
...transDataToDefs(d),
"!doc": btoa(JSON.stringify({ path: newPath, data: data[dataKey] })),
"!doc": encodeURI(
JSON.stringify({ path: newPath, data: data[dataKey] }),
),
}
} else {
def[dataKey] = {
"!type": transTernTypeName(data[dataKey]),
"!doc": btoa(JSON.stringify({ path: newPath, data: data[dataKey] })),
"!doc": encodeURI(
JSON.stringify({ path: newPath, data: data[dataKey] }),
),
}
}
}
Expand Down

0 comments on commit 4be4db4

Please sign in to comment.