Skip to content

Gracefully handle missing fingerprinted file #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/static/index.js
Original file line number Diff line number Diff line change
@@ -24,7 +24,7 @@ module.exports = function _static (asset, options = {}) {
let pkg = JSON.parse(read(manifest))
let asset = pkg[key]
if (!asset)
throw ReferenceError(`Could not find asset in static.json (asset fingerprint manifest): ${key}`)
return `${path}/${key}`
return `${path}/${asset}`
}
return `${path}/${isIndex ? '' : key}`
9 changes: 4 additions & 5 deletions test/unit/src/static/index-test.js
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ test('Staging env returns non-fingerprinted path if static manifest is not prese
t.equal(asset, '/_static/foo.png', 'Returned non-fingerprinted path')
})

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

test('Staging env returns non-fingerprinted path if static manifest is present', t => {
test('Staging env returns non-fingerprinted path if file is not present in static manifest mapping', t => {
t.plan(1)
reset()
manifestExists = true
process.env.NODE_ENV = 'staging'
t.throws(() => {
arcStatic('bar.png')
}, 'Static helper throws error if asset is not found')
let asset = arcStatic('bar.png')
t.equal(asset, '/_static/bar.png', 'Returned non-fingerprinted path')
})

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