Skip to content

Commit cf2a152

Browse files
committed
remove dep "string"; closes watson-developer-cloud#502
1 parent d5909a1 commit cf2a152

File tree

3 files changed

+35
-44
lines changed

3 files changed

+35
-44
lines changed

lib/requestwrapper.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const extend = require('extend');
2020
const request = require('request');
2121
const pkg = require('../package.json');
2222
const helper = require('./helper');
23-
const parseString = require('string');
2423
const readableStream = require('stream').PassThrough;
2524
const isBrowser = typeof window === 'object';
2625

@@ -34,12 +33,10 @@ function parsePath(path, params) {
3433
if (!path || !params) {
3534
return path;
3635
}
37-
const escapedParams = {};
38-
Object.keys(params).forEach(function(value) {
39-
escapedParams[value] = encodeURIComponent(params[value]);
40-
});
41-
42-
return parseString(path).template(escapedParams, '{', '}').s;
36+
return Object.keys(params).reduce((parsedPath, param) => {
37+
const value = encodeURIComponent(params[param]);
38+
return parsedPath.replace(new RegExp(`{${param}}`), value);
39+
}, path);
4340
}
4441

4542
/**

package-lock.json

Lines changed: 31 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@
9696
"object.pick": "~1.3.0",
9797
"request": "~2.81.0",
9898
"solr-client": "^0.7.0",
99-
"string": "3.3.3",
10099
"vcap_services": "~0.3.0",
101100
"websocket": "~1.0.22"
102101
},

0 commit comments

Comments
 (0)