mike-jumper commented on code in PR #778:
URL: https://github.com/apache/guacamole-client/pull/778#discussion_r1035335604


##########
guacamole/src/main/frontend/src/app/storage/services/localStorageService.js:
##########
@@ -119,10 +122,18 @@ angular.module('storage').provider('localStorageService', 
[function localStorage
         }
         catch (ignore) {}
 
-        // Pull and parse value from internal storage, if present
+        // Pull from internal storage, if present
         var data = storedItems[key];
-        if (data)
-            return JSON.parse(data);
+        if (data) {
+
+            // Serialize to JSON if possible
+            try {
+                return JSON.stringify(value);
+            } catch (ignore) {}

Review Comment:
   I think you mean `JSON.parse()` here, but I also don't think we should 
attempt to parse values that we expect may not be JSON, as doing so introduces 
ambiguity (a value intended to be stored as a string may happen to also be 
valid JSON).
   
   We could universally store everything as JSON, in which case a string would 
just be stored as a JSON string, or we could provide functions that are 
specifically intended for storage/retrieval of only string values.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to