Skip to content

Commit 5b84c4c

Browse files
committed
Encode slashes in path parameters
Slashes in path parameters should be encoded in order to produce valid URLs. Fixes: swagger-api#1013
1 parent 9ba4683 commit 5b84c4c

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

dist/lib/swagger-client.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,18 +1464,7 @@ Operation.prototype.encodeQueryParam = function(arg) {
14641464
* TODO revisit, might not want to leave '/'
14651465
**/
14661466
Operation.prototype.encodePathParam = function(pathParam) {
1467-
var encParts, part, parts, i, len;
1468-
pathParam = pathParam.toString();
1469-
if (pathParam.indexOf('/') === -1) {
1470-
return encodeURIComponent(pathParam);
1471-
} else {
1472-
parts = pathParam.split('/');
1473-
encParts = [];
1474-
for (i = 0, len = parts.length; i < len; i++) {
1475-
encParts.push(encodeURIComponent(parts[i]));
1476-
}
1477-
return encParts.join('/');
1478-
}
1467+
return encodeURIComponent(pathParam.toString());
14791468
};
14801469

14811470
var Model = function(name, definition) {

lib/swagger-client.js

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,18 +1464,7 @@ Operation.prototype.encodeQueryParam = function(arg) {
14641464
* TODO revisit, might not want to leave '/'
14651465
**/
14661466
Operation.prototype.encodePathParam = function(pathParam) {
1467-
var encParts, part, parts, i, len;
1468-
pathParam = pathParam.toString();
1469-
if (pathParam.indexOf('/') === -1) {
1470-
return encodeURIComponent(pathParam);
1471-
} else {
1472-
parts = pathParam.split('/');
1473-
encParts = [];
1474-
for (i = 0, len = parts.length; i < len; i++) {
1475-
encParts.push(encodeURIComponent(parts[i]));
1476-
}
1477-
return encParts.join('/');
1478-
}
1467+
return encodeURIComponent(pathParam.toString());
14791468
};
14801469

14811470
var Model = function(name, definition) {

0 commit comments

Comments
 (0)