Skip to content

Commit 709f56f

Browse files
authored
Added Param Extractor to remove unused params in URL
1 parent 85e5c03 commit 709f56f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/actions/Action.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ export default class Action {
4949
*/
5050
static transformParams (type, model, config = {}) {
5151
let endpoint = `${model.methodConf.http.url}${model.methodConf.methods[type].http.url}`;
52-
if (config.params) _.forOwn(config.params, (value, param) => { endpoint = endpoint.replace(`:${param}`, value); });
52+
let params = _.map(endpoint.match(/(\/?)(\:)([A-z]*)/gm), (param) => { return param.replace('/', '') })
53+
_.forEach(params, (param) => { endpoint = endpoint.replace(param, config.params[param.replace(':')] ? foundParam : '').replace('//', '/') })
5354
if (config.query) endpoint += `?${Object.keys(config.query).map(k => `${encodeURIComponent(k)}=${encodeURIComponent(config.query[k])}`).join('&')}`;
5455
return endpoint;
5556
}

0 commit comments

Comments
 (0)