From 1cac8a53f910580d0df492f4e8c502c9f8699c66 Mon Sep 17 00:00:00 2001 From: Jack Lukic Date: Tue, 11 Aug 2015 12:02:14 -0400 Subject: [PATCH] Fix parameters being encoded by default in tab, add encodeParameters setting to API #2752 --- RELEASE-NOTES.md | 1 + src/definitions/behaviors/api.js | 14 ++++++++++---- src/definitions/modules/tab.js | 9 +++++---- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 01decd8714..491bf99619 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -10,6 +10,7 @@ - **Button** - Added `labeled button` variation for display a count next to a button. - **Divider** - Vertical divider can now be used multiple times in a single column row (not just 50/50 split). #2808 - **Input** - Added `disabled` state for inputs #2694 +- **API** - Added `encodeParameters` option to enable/disable parameters being encoded with `encodeURIComponent` #2752 **Additional Enhancements** - **Menu** - `text menu` now uses padding for hitboxes to make target area for links larger diff --git a/src/definitions/behaviors/api.js b/src/definitions/behaviors/api.js index 401d6f9a21..2c3845ef09 100644 --- a/src/definitions/behaviors/api.js +++ b/src/definitions/behaviors/api.js @@ -109,7 +109,7 @@ $.api = $.fn.api = function(parameters) { ; } else if(settings.on == 'now') { - module.debug('Querying API now', triggerEvent); + module.debug('Querying API endpoint immediately'); module.query(); } } @@ -358,7 +358,11 @@ $.api = $.fn.api = function(parameters) { } else { module.verbose('Found required variable', variable, value); - url = url.replace(templatedString, module.get.urlEncodedValue(value)); + value = (settings.encodeParameters) + ? module.get.urlEncodedValue(value) + : value + ; + url = url.replace(templatedString, value); } }); } @@ -724,7 +728,7 @@ $.api = $.fn.api = function(parameters) { module.debug('URL value is already encoded, avoiding double encoding', value); return value; } - module.verbose('Encoding value for url', value, encodedValue); + module.verbose('Encoding value using encodeURIComponent', value, encodedValue); return encodedValue; }, defaultData: function() { @@ -990,7 +994,7 @@ $.api.settings = { name : 'API', namespace : 'api', - debug : true, + debug : false, verbose : false, performance : true, @@ -1015,6 +1019,8 @@ $.api.settings = { // duration for error state errorDuration : 2000, + encodeParameters : true, + // API action to use action : false, diff --git a/src/definitions/modules/tab.js b/src/definitions/modules/tab.js index e1860d8b30..ee91e30b7f 100644 --- a/src/definitions/modules/tab.js +++ b/src/definitions/modules/tab.js @@ -440,10 +440,11 @@ $.fn.tab = function(parameters) { var $tab = module.get.tabElement(tabPath), apiSettings = { - dataType : 'html', - on : 'now', - cache : settings.alwaysRefresh, - headers : { + dataType : 'html', + encodeParameters : false, + on : 'now', + cache : settings.alwaysRefresh, + headers : { 'X-Remote': true }, onSuccess : function(response) {