Skip to content

Commit e1c93b1

Browse files
committed
Allow urlPath override for httpAdapter
1 parent e41418a commit e1c93b1

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Diff for: src/index.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,18 @@ class DSHttpAdapter {
9797
getPath(method, resourceConfig, id, options) {
9898
let _this = this;
9999
options = options || {};
100-
let args = [
101-
options.basePath || _this.defaults.basePath || resourceConfig.basePath,
102-
this.getEndpoint(resourceConfig, (isString(id) || isNumber(id) || method === 'create') ? id : null, options)
103-
];
104-
if (method === 'find' || method === 'update' || method === 'destroy') {
105-
args.push(id);
100+
if (isString(options.urlPath)) {
101+
return makePath.apply(DSUtils, [options.basePath || _this.defaults.basePath || resourceConfig.basePath, options.urlPath.split('/')]);
102+
} else {
103+
let args = [
104+
options.basePath || _this.defaults.basePath || resourceConfig.basePath,
105+
this.getEndpoint(resourceConfig, (isString(id) || isNumber(id) || method === 'create') ? id : null, options)
106+
];
107+
if (method === 'find' || method === 'update' || method === 'destroy') {
108+
args.push(id);
109+
}
110+
return makePath.apply(DSUtils, args);
106111
}
107-
return makePath.apply(DSUtils, args);
108112
}
109113

110114
HTTP(config) {
@@ -289,4 +293,3 @@ class DSHttpAdapter {
289293
}
290294

291295
module.exports = DSHttpAdapter;
292-

0 commit comments

Comments
 (0)