From 84fe876499fc7802e7ba91a881ef50d963741803 Mon Sep 17 00:00:00 2001 From: Lars Trieloff Date: Fri, 3 May 2019 13:19:33 +0000 Subject: [PATCH] fix(static): always return entry path for 404 errors --- src/openwhisk/static.js | 5 ++++- test/testStatic.js | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/openwhisk/static.js b/src/openwhisk/static.js index c8133c44a..64140158e 100644 --- a/src/openwhisk/static.js +++ b/src/openwhisk/static.js @@ -45,7 +45,7 @@ function error(message, code = 500) { 'Content-Type': 'text/html', 'X-Static': 'Raw/Static', }, - body: `Error ${code}: ${message}`, + body: `${message}`, }; } @@ -281,6 +281,9 @@ function deliverPlain(owner, repo, ref, entry, root, esi = false) { body: entry, }; } + if (rqerror.statusCode==404) { + return error(entry, rqerror.statusCode); + } return error(rqerror.response.body.toString(), rqerror.statusCode); }); } diff --git a/test/testStatic.js b/test/testStatic.js index bbad26b8a..e767e70b4 100644 --- a/test/testStatic.js +++ b/test/testStatic.js @@ -194,7 +194,7 @@ describe('Static Delivery Action #unittest', () => { it('error() #unittest', () => { const error = index.error('Test'); assert.equal(error.statusCode, '500'); - assert.ok(error.body.match('500')); + assert.ok(error.body.match('Test')); assert.ok(!error.body.match('404')); });