Skip to content

Commit

Permalink
Fix parameters being encoded by default in tab, add encodeParameters …
Browse files Browse the repository at this point in the history
…setting to API #2752
  • Loading branch information
jlukic committed Aug 11, 2015
1 parent b615696 commit 1cac8a5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions src/definitions/behaviors/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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);
}
});
}
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -990,7 +994,7 @@ $.api.settings = {
name : 'API',
namespace : 'api',

debug : true,
debug : false,
verbose : false,
performance : true,

Expand All @@ -1015,6 +1019,8 @@ $.api.settings = {
// duration for error state
errorDuration : 2000,

encodeParameters : true,

// API action to use
action : false,

Expand Down
9 changes: 5 additions & 4 deletions src/definitions/modules/tab.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 1cac8a5

Please sign in to comment.