diff --git a/dist/index.js b/dist/index.js index 6bef895..cf59f00 100644 --- a/dist/index.js +++ b/dist/index.js @@ -18,6 +18,10 @@ var _templateUrl = require('template-url'); var _templateUrl2 = _interopRequireDefault(_templateUrl); +var _urlJoin = require('url-join'); + +var _urlJoin2 = _interopRequireDefault(_urlJoin); + function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var replaceWithActions = function replaceWithActions(out, start, options) { @@ -29,6 +33,7 @@ var replaceWithActions = function replaceWithActions(out, start, options) { } out[k] = (0, _tahoe.createAction)((0, _extends3.default)({ endpoint: function endpoint(opt) { + if (options.rootUrl) return (0, _urlJoin2.default)(options.rootUrl, (0, _templateUrl2.default)(v.path, opt)); return (0, _templateUrl2.default)(v.path, opt); }, method: v.method, diff --git a/package.json b/package.json index 62ef1de..bf0aeb3 100644 --- a/package.json +++ b/package.json @@ -84,6 +84,7 @@ "dependencies": { "babel-runtime": "^6.11.6", "tahoe": "^1.0.0", - "template-url": "^1.0.0" + "template-url": "^1.0.0", + "url-join": "^2.0.2" } } diff --git a/src/index.js b/src/index.js index f2951f7..609950f 100644 --- a/src/index.js +++ b/src/index.js @@ -1,5 +1,6 @@ import { createAction } from 'tahoe' import template from 'template-url' +import uJoin from 'url-join' const replaceWithActions = (out, start, options) => { Object.keys(start).forEach((k) => { @@ -9,7 +10,10 @@ const replaceWithActions = (out, start, options) => { return } out[k] = createAction({ - endpoint: (opt) => template(v.path, opt), + endpoint: (opt) => { + if (options.rootUrl) return uJoin(options.rootUrl, template(v.path, opt)) + return template(v.path, opt) + }, method: v.method, credentials: 'include', ...options