Browse Source

#2394 URL values will now encode while avoiding double encoding

pull/2710/head
jlukic 9 years ago
parent
commit
fc6df94ea3
1 changed files with 14 additions and 1 deletions
  1. 15
      src/definitions/behaviors/api.js

15
src/definitions/behaviors/api.js

@ -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));
}
});
}
@ -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 = {}

Loading…
Cancel
Save