Permalink
Browse files

fix(rest): convert number to string before joining path

  • Loading branch information...
doktordirk committed Aug 19, 2016
1 parent 191b06c commit 34e8ba1c9db579411ba86a4877813bf11cd9e488
Showing with 6 additions and 1 deletion.
  1. +1 −1 src/rest.js
  2. +5 −0 test/rest.spec.js
@@ -218,7 +218,7 @@ function getRequestPath(resource: string, idOrCriteria: string|Number|{}, criter
let hasSlash = resource.slice(-1) === '/';

if (typeof idOrCriteria === 'string' || typeof idOrCriteria === 'number') {
resource = `${join(resource, idOrCriteria)}${hasSlash ? '/' : ''}`;
resource = `${join(resource, String(idOrCriteria))}${hasSlash ? '/' : ''}`;
} else {
criteria = idOrCriteria;
}
@@ -51,6 +51,11 @@ describe('Rest', function() {
expect(y.path).toBe('/posts/id');
expect(JSON.stringify(y.query)).toBe('{}');
}),
injectTest.apiEndpoint.find('posts', 1)
.then(y => {
expect(y.path).toBe('/posts/1');
expect(JSON.stringify(y.query)).toBe('{}');
}),
injectTest.apiEndpoint.find('posts/', 'id')
.then(y => {
expect(y.path).toBe('/posts/id/');

0 comments on commit 34e8ba1

Please sign in to comment.