From 301520f3fdd49a88c006f9db4ef8a0707f010184 Mon Sep 17 00:00:00 2001 From: eranroz Date: Thu, 16 Jul 2015 13:13:57 +0300 Subject: [PATCH] Avoid (safe) exception by using empty options Using try-catch block to handle common case of empty options isn't nice. Avoid it be replacing options to valid JSON Change-Id: I5b64f7f9a76a94d9c07face8059beab59d4aef93 --- resources/js/ext.uls.preferences.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/js/ext.uls.preferences.js b/resources/js/ext.uls.preferences.js index 0229e012..36f96d2c 100644 --- a/resources/js/ext.uls.preferences.js +++ b/resources/js/ext.uls.preferences.js @@ -101,7 +101,9 @@ this.preferences = preferenceStore().get( this.preferenceName ); } else { var options = mw.user.options.get( this.preferenceName ); - + if ( !options ) { + options = '{}'; + } // Try to parse JSON try { this.preferences = JSON.parse( options );