Skip to content

Commit cbe6c9e

Browse files
authored
Merge pull request #334 from herschel666/gracefully-handle-missing-fingerprinted-file
Gracefully handle missing fingerprinted file
2 parents bde1ea0 + fde9b29 commit cbe6c9e

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/static/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ module.exports = function _static (asset, options = {}) {
2525
let pkg = JSON.parse(read(manifest))
2626
let asset = pkg[key]
2727
if (!asset)
28-
throw ReferenceError(`Could not find asset in static.json (asset fingerprint manifest): ${key}`)
28+
return `${path}/${key}`
2929
return `${path}/${asset}`
3030
}
3131
return `${path}/${isIndex ? '' : key}`

test/unit/src/static/index-test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ test('Staging env returns non-fingerprinted path if static manifest is not prese
5151
t.equal(asset, '/_static/foo.png', 'Returned non-fingerprinted path')
5252
})
5353

54-
test('Staging env returns non-fingerprinted path if static manifest is present', t => {
54+
test('Staging env returns fingerprinted path if static manifest is present', t => {
5555
t.plan(1)
5656
reset()
5757
manifestExists = true
@@ -60,14 +60,13 @@ test('Staging env returns non-fingerprinted path if static manifest is present',
6060
t.equal(asset, '/_static/foo-1a2b3d.png', 'Returned fingerprinted path')
6161
})
6262

63-
test('Staging env returns non-fingerprinted path if static manifest is present', t => {
63+
test('Staging env returns non-fingerprinted path if file is not present in static manifest mapping', t => {
6464
t.plan(1)
6565
reset()
6666
manifestExists = true
6767
process.env.ARC_ENV = 'staging'
68-
t.throws(() => {
69-
arcStatic('bar.png')
70-
}, 'Static helper throws error if asset is not found')
68+
let asset = arcStatic('bar.png')
69+
t.equal(asset, '/_static/bar.png', 'Returned non-fingerprinted path')
7170
})
7271

7372
test('Passing stagePath option adds API Gateway /staging or /production to path', t => {

0 commit comments

Comments
 (0)