Skip to content

Commit

Permalink
#2394 URL values will now encode while avoiding double encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
jlukic committed Jul 20, 2015
1 parent c82c668 commit fc6df94
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/definitions/behaviors/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ $.api = $.fn.api = function(parameters) {
}
else {
module.verbose('Found required variable', variable, value);
url = url.replace(templatedString, value);
url = url.replace(templatedString, module.get.urlEncodedValue(value));
}
});
}
Expand Down Expand Up @@ -686,6 +686,19 @@ $.api = $.fn.api = function(parameters) {
: settings
;
},
urlEncodedValue: function(value) {
var
decodedValue = window.decodeURIComponent(value),
encodedValue = window.encodeURIComponent(value),
alreadyEncoded = (decodedValue !== value)
;
if(alreadyEncoded) {
module.debug('URL value is already encoded, avoiding double encoding', value);
return value;
}
module.verbose('Encoding value for url', value, encodedValue);
return encodedValue;
},
defaultData: function() {
var
data = {}
Expand Down

0 comments on commit fc6df94

Please sign in to comment.