diff --git a/lib/rest-adapter.js b/lib/rest-adapter.js index eb1f48f..ac39701 100644 --- a/lib/rest-adapter.js +++ b/lib/rest-adapter.js @@ -584,7 +584,7 @@ RestAdapter.prototype.allRoutes = function() { path = currentRoot + path; } - if (path[path.length - 1] === '/') { + if (path.length > 1 && path[path.length - 1] === '/') { path = path.substr(0, path.length - 1); } diff --git a/test/rest-adapter.test.js b/test/rest-adapter.test.js index 74b9366..bb0e19b 100644 --- a/test/rest-adapter.test.js +++ b/test/rest-adapter.test.js @@ -595,6 +595,18 @@ describe('RestAdapter', function() { const allRoutes = restAdapter.allRoutes(); expect(allRoutes[0]).to.have.property('http'); }); + + it('does not alter / paths', function() { + const remotes = RemoteObjects.create({cors: false}); + remotes.exports.testClass = factory.createSharedClass(); + remotes.exports.testClass.http = {path: '/', verb: 'any'}; + remotes.exports.testClass.sharedCtor.accepts = []; + remotes.exports.testClass.sharedCtor.http = {path: '/', verb: 'patch'}; + + const restAdapter = new RestAdapter(remotes); + const allRoutes = restAdapter.allRoutes(); + expect(allRoutes[0].path).to.equal('/'); + }); }); });