diff --git a/flaska.mjs b/flaska.mjs index 732d9a2..29b2fe5 100644 --- a/flaska.mjs +++ b/flaska.mjs @@ -487,6 +487,9 @@ export class Flaska { 'OPTIONS': new FlaskaRouter(), 'PATCH': new FlaskaRouter(), } + // HEAD and GET should be identical + this.routers['HEAD'] = this.routers['GET'] + this.get = this.routers.GET.addRoute.bind(this.routers.GET) this.post = this.routers.POST.addRoute.bind(this.routers.POST) this.put = this.routers.PUT.addRoute.bind(this.routers.PUT) diff --git a/test/flaska.api.test.mjs b/test/flaska.api.test.mjs index 747dae2..9823da9 100644 --- a/test/flaska.api.test.mjs +++ b/test/flaska.api.test.mjs @@ -25,6 +25,15 @@ t.test('it should have all the common verbs', function() { assert.strictEqual(typeof(flaska.patch), 'function') }) +t.test('the verbs GET and HEAD should be identical', function() { + let flaska = new Flaska({}, faker) + assert.ok(flaska.get) + assert.strictEqual(typeof(flaska.get), 'function') + assert.notOk(flaska.head) + assert.ok(flaska.routers['HEAD']) + assert.strictEqual(flaska.routers['GET'], flaska.routers['HEAD']) +}) + t.describe('#log', function() { t.test('default have a logger valid', function() { let flaska = new Flaska({}, faker)