Parcourir la source

Improved custom settings parsing

dosse91 il y a 9 ans
Parent
commit
b0172cc108
2 fichiers modifiés avec 5 ajouts et 1 suppressions
  1. 5 1
      speedtest_worker.js
  2. 0 0
      speedtest_worker.min.js

+ 5 - 1
speedtest_worker.js

@@ -68,7 +68,11 @@ this.addEventListener('message', function (e) {
     testStatus = 1
     try {
       // parse settings, if present
-      var s = JSON.parse(e.data.substring(5))
+      var s = {}
+      try{
+        var ss = e.data.substring(5);
+        if (ss) s = JSON.parse(ss);
+      }catch(e){ console.warn("Error parsing custom settings JSON. Please check your syntax"); }
       if (typeof s.url_dl !== 'undefined') settings.url_dl = s.url_dl // download url
       if (typeof s.url_ul !== 'undefined') settings.url_ul = s.url_ul // upload url
       if (typeof s.url_ping !== 'undefined') settings.url_ping = s.url_ping // ping url

Fichier diff supprimé car celui-ci est trop grand
+ 0 - 0
speedtest_worker.min.js


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff