Skip to content

Commit

Permalink
rebased, merged #280
Browse files Browse the repository at this point in the history
  • Loading branch information
fehguy committed Jun 3, 2015
1 parent 74e24e5 commit b6f5dbc
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 49 deletions.
19 changes: 2 additions & 17 deletions browser/swagger-client.js

Large diffs are not rendered by default.

17 changes: 1 addition & 16 deletions browser/swagger-client.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -3421,22 +3421,7 @@ Operation.prototype.encodeQueryParam = function (arg) {
* TODO revisit, might not want to leave '/'
**/
Operation.prototype.encodePathParam = function (pathParam) {
var encParts, parts, i, len;

pathParam = pathParam.toString();

if (pathParam.indexOf('/') === -1) {
return encodeURIComponent(pathParam);
} else {
parts = pathParam.split('/');
encParts = [];

for (i = 0, len = parts.length; i < len; i++) {
encParts.push(encodeURIComponent(parts[i]));
}

return encParts.join('/');
}
return encodeURIComponent(pathParam);
};

},{"../helpers":4,"../http":5,"./model":8,"lodash-compat/lang/cloneDeep":126,"lodash-compat/lang/isUndefined":135}],10:[function(require,module,exports){
Expand Down
17 changes: 1 addition & 16 deletions lib/types/operation.js
Original file line number Diff line number Diff line change
Expand Up @@ -888,20 +888,5 @@ Operation.prototype.encodeQueryParam = function (arg) {
* TODO revisit, might not want to leave '/'
**/
Operation.prototype.encodePathParam = function (pathParam) {
var encParts, parts, i, len;

pathParam = pathParam.toString();

if (pathParam.indexOf('/') === -1) {
return encodeURIComponent(pathParam);
} else {
parts = pathParam.split('/');
encParts = [];

for (i = 0, len = parts.length; i < len; i++) {
encParts.push(encodeURIComponent(parts[i]));
}

return encParts.join('/');
}
return encodeURIComponent(pathParam);
};
11 changes: 11 additions & 0 deletions test/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,4 +321,15 @@ describe('swagger request functions', function () {
done();
});
});

it('escapes a param per #280', function () {
var petApi = sample.pet;
var req = petApi.getPetById({petId: 'foo/bar'}, {mock: true});

test.object(req);

expect(req.method).toBe('GET');
expect(req.headers.Accept).toBe('application/json');
expect(req.url).toBe('http://localhost:8000/v2/api/pet/foo%2Fbar');
});
});

0 comments on commit b6f5dbc

Please sign in to comment.