-
Notifications
You must be signed in to change notification settings - Fork 29.4k
Fix image optimization encoding url #28045
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
044e471
Fix image optimization encoding url
styfle 00e5274
Revert unnecesary change
styfle 2a5052f
Add another test for percent
styfle 8dd6bf2
Fix test with space
styfle 1a9e3fc
Merge branch 'canary' into fix-unicode-and-url-encoding
styfle fbbef8f
Remove unused domain
styfle dad7014
Merge branch 'canary' into fix-unicode-and-url-encoding
styfle c74923c
Fix next server serving unicode files
styfle 9136c59
Add old test back
styfle 146565c
Add comment
styfle a9ed1e3
Merge branch 'canary' into fix-unicode-and-url-encoding
kodiakhq[bot] 9ce365e
Fix lint
styfle File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
images: { | ||
domains: ['image-optimization-test.vercel.app'], | ||
}, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react' | ||
import Image from 'next/image' | ||
import img from '../public/äöü.png' | ||
|
||
const Page = () => { | ||
return ( | ||
<div> | ||
<h1>Unicode Image URL</h1> | ||
<Image id="static" src={img} /> | ||
<Image id="internal" src="/äöü.png" width={400} height={400} /> | ||
<Image | ||
id="external" | ||
src="https://image-optimization-test.vercel.app/äöü.png" | ||
width={400} | ||
height={400} | ||
/> | ||
<Image | ||
id="internal-space" | ||
src="/hello%20world.jpg" | ||
width={200} | ||
height={200} | ||
/> | ||
<Image | ||
id="external-space" | ||
src="https://image-optimization-test.vercel.app/hello%20world.jpg" | ||
width={200} | ||
height={200} | ||
/> | ||
</div> | ||
) | ||
} | ||
|
||
export default Page |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions
96
test/integration/image-component/unicode/test/index.test.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* eslint-env jest */ | ||
|
||
import { | ||
findPort, | ||
killApp, | ||
launchApp, | ||
nextBuild, | ||
nextStart, | ||
} from 'next-test-utils' | ||
import webdriver from 'next-webdriver' | ||
//import fetch from 'node-fetch' | ||
import { join } from 'path' | ||
|
||
jest.setTimeout(1000 * 60) | ||
|
||
const appDir = join(__dirname, '../') | ||
|
||
let appPort | ||
let app | ||
let browser | ||
|
||
function runTests() { | ||
it('should load static unicode image', async () => { | ||
const src = await browser.elementById('static').getAttribute('src') | ||
expect(src).toMatch( | ||
/_next%2Fstatic%2Fimage%2Fpublic%2F%C3%A4%C3%B6%C3%BC(.+)png/ | ||
) | ||
const res = await fetch(src) | ||
expect(res.status).toBe(200) | ||
}) | ||
|
||
it('should load internal unicode image', async () => { | ||
const src = await browser.elementById('internal').getAttribute('src') | ||
expect(src).toMatch('/_next/image?url=%2F%C3%A4%C3%B6%C3%BC.png') | ||
const res = await fetch(src) | ||
expect(res.status).toBe(200) | ||
}) | ||
|
||
it('should load external unicode image', async () => { | ||
const src = await browser.elementById('external').getAttribute('src') | ||
expect(src).toMatch( | ||
'/_next/image?url=https%3A%2F%2Fimage-optimization-test.vercel.app%2F%C3%A4%C3%B6%C3%BC.png' | ||
) | ||
const res = await fetch(src) | ||
expect(res.status).toBe(200) | ||
}) | ||
|
||
it('should load internal image with space', async () => { | ||
const src = await browser.elementById('internal-space').getAttribute('src') | ||
expect(src).toMatch('/_next/image?url=%2Fhello%2520world.jpg') | ||
const res = await fetch(src) | ||
expect(res.status).toBe(200) | ||
}) | ||
|
||
it('should load external image with space', async () => { | ||
const src = await browser.elementById('external-space').getAttribute('src') | ||
expect(src).toMatch( | ||
'/_next/image?url=https%3A%2F%2Fimage-optimization-test.vercel.app%2Fhello%2520world.jpg' | ||
) | ||
const res = await fetch(src) | ||
expect(res.status).toBe(200) | ||
}) | ||
} | ||
|
||
describe('Image Component Unicode Image URL', () => { | ||
describe('dev mode', () => { | ||
beforeAll(async () => { | ||
appPort = await findPort() | ||
app = await launchApp(appDir, appPort) | ||
browser = await webdriver(appPort, '/') | ||
}) | ||
afterAll(() => { | ||
killApp(app) | ||
if (browser) { | ||
browser.close() | ||
} | ||
}) | ||
runTests() | ||
}) | ||
|
||
describe('server mode', () => { | ||
beforeAll(async () => { | ||
await nextBuild(appDir) | ||
appPort = await findPort() | ||
app = await nextStart(appDir, appPort) | ||
browser = await webdriver(appPort, '/') | ||
}) | ||
afterAll(() => { | ||
killApp(app) | ||
if (browser) { | ||
browser.close() | ||
} | ||
}) | ||
runTests() | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.