Skip to content

Commit b6f5dbc

Browse files
committed
rebased, merged #280
1 parent 74e24e5 commit b6f5dbc

File tree

4 files changed

+15
-49
lines changed

4 files changed

+15
-49
lines changed

browser/swagger-client.js

+2-17
Large diffs are not rendered by default.

browser/swagger-client.min.js

+1-16
Original file line numberDiff line numberDiff line change
@@ -3421,22 +3421,7 @@ Operation.prototype.encodeQueryParam = function (arg) {
34213421
* TODO revisit, might not want to leave '/'
34223422
**/
34233423
Operation.prototype.encodePathParam = function (pathParam) {
3424-
var encParts, parts, i, len;
3425-
3426-
pathParam = pathParam.toString();
3427-
3428-
if (pathParam.indexOf('/') === -1) {
3429-
return encodeURIComponent(pathParam);
3430-
} else {
3431-
parts = pathParam.split('/');
3432-
encParts = [];
3433-
3434-
for (i = 0, len = parts.length; i < len; i++) {
3435-
encParts.push(encodeURIComponent(parts[i]));
3436-
}
3437-
3438-
return encParts.join('/');
3439-
}
3424+
return encodeURIComponent(pathParam);
34403425
};
34413426

34423427
},{"../helpers":4,"../http":5,"./model":8,"lodash-compat/lang/cloneDeep":126,"lodash-compat/lang/isUndefined":135}],10:[function(require,module,exports){

lib/types/operation.js

+1-16
Original file line numberDiff line numberDiff line change
@@ -888,20 +888,5 @@ Operation.prototype.encodeQueryParam = function (arg) {
888888
* TODO revisit, might not want to leave '/'
889889
**/
890890
Operation.prototype.encodePathParam = function (pathParam) {
891-
var encParts, parts, i, len;
892-
893-
pathParam = pathParam.toString();
894-
895-
if (pathParam.indexOf('/') === -1) {
896-
return encodeURIComponent(pathParam);
897-
} else {
898-
parts = pathParam.split('/');
899-
encParts = [];
900-
901-
for (i = 0, len = parts.length; i < len; i++) {
902-
encParts.push(encodeURIComponent(parts[i]));
903-
}
904-
905-
return encParts.join('/');
906-
}
891+
return encodeURIComponent(pathParam);
907892
};

test/request.js

+11
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,15 @@ describe('swagger request functions', function () {
321321
done();
322322
});
323323
});
324+
325+
it('escapes a param per #280', function () {
326+
var petApi = sample.pet;
327+
var req = petApi.getPetById({petId: 'foo/bar'}, {mock: true});
328+
329+
test.object(req);
330+
331+
expect(req.method).toBe('GET');
332+
expect(req.headers.Accept).toBe('application/json');
333+
expect(req.url).toBe('http://localhost:8000/v2/api/pet/foo%2Fbar');
334+
});
324335
});

0 commit comments

Comments
 (0)