diff --git a/lib/Application.js b/lib/Application.js index 82d36d2..4dbd576 100644 --- a/lib/Application.js +++ b/lib/Application.js @@ -45,7 +45,7 @@ class Application { // If the view or the entity don't define the url, retrieve it from the baseURL of the entity or the app if (!url) { url = baseApiUrl + entity.name(); - if (identifierValue) { + if (identifierValue != null) { url += '/' + identifierValue; } } else if (!/^(?:[a-z]+:)?\/\//.test(url)) { diff --git a/package.json b/package.json index e578dda..3537732 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "admin-config", - "version": "0.5.0", + "version": "0.5.1", "private": false, "repository": { "type": "git", diff --git a/tests/lib/ApplicationTest.js b/tests/lib/ApplicationTest.js index 7d57b0e..4e13bce 100644 --- a/tests/lib/ApplicationTest.js +++ b/tests/lib/ApplicationTest.js @@ -16,6 +16,13 @@ describe('Application', function() { assert.equal('posts/12', application.getRouteFor(entity, view.getUrl(12), view.type, 12, view.identifier())); }); + it('should work for zero indentifier', function() { + var application = new Application(); + var entity = new Entity('posts'); + application.addEntity(entity); + assert.equal('posts/0', application.getRouteFor(entity, null, null, 0, null)); + }); + it('should use the application baseApiUrl when provided', function() { var application = new Application(); application.baseApiUrl('/foo/'); @@ -231,7 +238,7 @@ describe('Application', function() { it('should serve as a setter', () => { let dashboard = new Dashboard(); - const collection = { IAmAFakeCollection: true, name: () => 'foo' }; + const collection = { IAmAFakeCollection: true, name: () => 'foo' }; dashboard.addCollection(collection) let application = new Application(); application.dashboard(dashboard); @@ -270,7 +277,7 @@ describe('Application', function() { new Field('field1'), new Field('field2'), new Field('field3'), - new Field('field4') + new Field('field4') ]; comment.listView().fields(fields);