Skip to content

Commit f8fd63a

Browse files
Merge branch 'canary' into not-found/fix-blocking-ssg-404
2 parents df4de02 + f7ba546 commit f8fd63a

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

packages/next/next-server/server/config.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -218,18 +218,12 @@ function assignDefaults(userConfig: { [key: string]: any }) {
218218
if (result?.images) {
219219
const { images } = result
220220

221-
// Normalize defined image host to end in slash
222-
if (images?.path) {
223-
if (images.path[images.path.length - 1] !== '/') {
224-
images.path += '/'
225-
}
226-
}
227-
228221
if (typeof images !== 'object') {
229222
throw new Error(
230223
`Specified images should be an object received ${typeof images}`
231224
)
232225
}
226+
233227
if (images.domains) {
234228
if (!Array.isArray(images.domains)) {
235229
throw new Error(
@@ -306,6 +300,14 @@ function assignDefaults(userConfig: { [key: string]: any }) {
306300
)
307301
}
308302
}
303+
304+
// Append trailing slash for non-default loaders
305+
if (images.path) {
306+
const isDefaultLoader = !images.loader || images.loader === 'default'
307+
if (!isDefaultLoader && images.path[images.path.length - 1] !== '/') {
308+
images.path += '/'
309+
}
310+
}
309311
}
310312

311313
if (result.experimental?.i18n) {

test/integration/image-component/default/test/index.test.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ function runTests(mode) {
7171
expect(
7272
await hasImageMatchingUrl(
7373
browser,
74-
mode === 'serverless'
75-
? // FIXME: this is a bug
76-
`http://localhost:${appPort}/_next/image/?url=%2Ftest.jpg&w=420&q=75`
77-
: `http://localhost:${appPort}/_next/image?url=%2Ftest.jpg&w=420&q=75`
74+
`http://localhost:${appPort}/_next/image?url=%2Ftest.jpg&w=420&q=75`
7875
)
7976
).toBe(true)
8077
} finally {

0 commit comments

Comments
 (0)