Browse Source

Fix GraphQL user crash with invalid JSON

Zed 3 năm trước cách đây
mục cha
commit
dcf73354ff
1 tập tin đã thay đổi với 3 bổ sung0 xóa
  1. 3 0
      src/experimental/parser/graphql.nim

+ 3 - 0
src/experimental/parser/graphql.nim

@@ -4,6 +4,9 @@ import user, ../types/[graphuser, graphlistmembers]
 from ../../types import User, Result, Query, QueryKind
 
 proc parseGraphUser*(json: string): User =
+  if json.len == 0 or json[0] != '{':
+    return
+
   let raw = json.fromJson(GraphUser)
 
   if raw.data.user.result.reason.get("") == "Suspended":