Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
N
next.js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alex
next.js
Commits
03b61778
Unverified
Commit
03b61778
authored
Jul 01, 2021
by
Steven
Committed by
GitHub
Jul 01, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix immutable header for image with static import & unoptimized (#26836)
Fixes #26587
parent
0562cc77
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
0 deletions
+32
-0
next-server.ts
packages/next/server/next-server.ts
+1
-0
static.js
test/integration/image-component/default/pages/static.js
+2
-0
static.test.js
test/integration/image-component/default/test/static.test.js
+29
-0
No files found.
packages/next/server/next-server.ts
View file @
03b61778
...
...
@@ -689,6 +689,7 @@ export default class Server {
params
.
path
[
0
]
===
CLIENT_STATIC_FILES_RUNTIME
||
params
.
path
[
0
]
===
'chunks'
||
params
.
path
[
0
]
===
'css'
||
params
.
path
[
0
]
===
'image'
||
params
.
path
[
0
]
===
'media'
||
params
.
path
[
0
]
===
this
.
buildId
||
params
.
path
[
0
]
===
'pages'
||
...
...
test/integration/image-component/default/pages/static.js
View file @
03b61778
...
...
@@ -45,6 +45,8 @@ const Page = () => {
<
Image
id
=
"static-gif"
src
=
{
testGIF
}
/
>
<
Image
id
=
"static-bmp"
src
=
{
testBMP
}
/
>
<
Image
id
=
"static-ico"
src
=
{
testICO
}
/
>
<
br
/>
<
Image
id
=
"static-unoptimized"
src
=
{
testJPG
}
unoptimized
/>
<
/div
>
)
}
...
...
test/integration/image-component/default/test/static.test.js
View file @
03b61778
...
...
@@ -5,6 +5,7 @@ import {
nextStart
,
renderViaHTTP
,
File
,
waitFor
,
}
from
'next-test-utils'
import
webdriver
from
'next-webdriver'
import
{
join
}
from
'path'
...
...
@@ -23,11 +24,39 @@ const runTests = () => {
it
(
'Should allow an image with a static src to omit height and width'
,
async
()
=>
{
expect
(
await
browser
.
elementById
(
'basic-static'
)).
toBeTruthy
()
expect
(
await
browser
.
elementById
(
'blur-png'
)).
toBeTruthy
()
expect
(
await
browser
.
elementById
(
'blur-webp'
)).
toBeTruthy
()
expect
(
await
browser
.
elementById
(
'blur-jpg'
)).
toBeTruthy
()
expect
(
await
browser
.
elementById
(
'static-svg'
)).
toBeTruthy
()
expect
(
await
browser
.
elementById
(
'static-gif'
)).
toBeTruthy
()
expect
(
await
browser
.
elementById
(
'static-bmp'
)).
toBeTruthy
()
expect
(
await
browser
.
elementById
(
'static-ico'
)).
toBeTruthy
()
expect
(
await
browser
.
elementById
(
'static-unoptimized'
)).
toBeTruthy
()
})
it
(
'Should use immutable cache-control header for static import'
,
async
()
=>
{
await
browser
.
eval
(
`document.getElementById("basic-static").scrollIntoView()`
)
await
waitFor
(
1000
)
const
url
=
await
browser
.
eval
(
`document.getElementById("basic-static").src`
)
const
res
=
await
fetch
(
url
)
expect
(
res
.
headers
.
get
(
'cache-control'
)).
toBe
(
'public, max-age=315360000, immutable'
)
})
it
(
'Should use immutable cache-control header even when unoptimized'
,
async
()
=>
{
await
browser
.
eval
(
`document.getElementById("static-unoptimized").scrollIntoView()`
)
await
waitFor
(
1000
)
const
url
=
await
browser
.
eval
(
`document.getElementById("static-unoptimized").src`
)
const
res
=
await
fetch
(
url
)
expect
(
res
.
headers
.
get
(
'cache-control'
)).
toBe
(
'public, max-age=31536000, immutable'
)
})
it
(
'Should automatically provide an image height and width'
,
async
()
=>
{
expect
(
html
).
toContain
(
'width:400px;height:300px'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment