File tree Expand file tree Collapse file tree 2 files changed +10
-11
lines changed
packages/next/next-server/server
test/integration/image-component/default/test Expand file tree Collapse file tree 2 files changed +10
-11
lines changed Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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 {
You can’t perform that action at this time.
0 commit comments