Next/Image SVG with Hash in URL
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Link to the code that reproduces this issue
https://github.com/ThomasAunvik/next-image-hash-in-svgimage
To Reproduce
- Generate SVG Image from https://github.com/jstrieb/github-stats
- Attempt use of Next/Image to the generated SVG.
- Add
#gh-dark-mode-onlyafter the url, as shown point 8 in https://github.com/jstrieb/github-stats#installation - See that the style of the svg is not set
- Use a direct img tag, and copy the next/image request url, remove the broken hash, and add to the correct way of hash.
Current vs. Expected behavior
I expected the URL of the request image to include the hash after the nextjs request url.
The result: The hash was url encoded with the image request, making it not apply styling trough the hash.
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: linux
Arch: x64
Version: #1 ZEN SMP PREEMPT_DYNAMIC Sat, 23 Sep 2023 22:54:46 +0000
Binaries:
Node: 20.8.0
npm: 10.1.0
Yarn: 1.22.19
pnpm: N/A
Relevant Packages:
next: 13.5.5-canary.0
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
typescript: 5.1.3
Next.js Config:
output: N/A
Which area(s) are affected? (Select all that apply)
Image optimization (next/image, next/legacy/image)
Additional context
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction at app/page.tsx lines 18-53 and compare the next/image request with the direct img request. Trace the Image Optimization entry point and URL handling for SVG fragments; done means the hash is preserved after the optimized image URL so the SVG styling applies. No test file is named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, next.js, react
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100