mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Fix a bug that Japanese files were not displayed correctly. (#9866)
* Fix: Fix a bug that Japanese files were not displayed correctly. * chore: generate change description * Update .changeset/cool-colts-watch.md * add test case for non-UTF-8 file name --------- Co-authored-by: Emanuele Stoppa <my.burning@gmail.com>
This commit is contained in:
parent
a994d609b3
commit
44c957f893
5 changed files with 13 additions and 2 deletions
5
.changeset/cool-colts-watch.md
Normal file
5
.changeset/cool-colts-watch.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
"@astrojs/markdown-remark": patch
|
||||
---
|
||||
|
||||
Fixes a bug where non-UTF-8 file names are not displayed when using relative paths in markdowns.
|
|
@ -51,8 +51,10 @@ describe('Assets Prefix - Static', () => {
|
|||
it('markdown image src start with assetsPrefix', async () => {
|
||||
const html = await fixture.readFile('/markdown/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
const imgAsset = $('img');
|
||||
expect(imgAsset.attr('src')).to.match(assetsPrefixRegex);
|
||||
const imgAssets = $('img');
|
||||
imgAssets.each((i, el) => {
|
||||
expect(el.attribs.src).to.match(assetsPrefixRegex);
|
||||
});
|
||||
});
|
||||
|
||||
it('content collections image src start with assetsPrefix', async () => {
|
||||
|
|
BIN
packages/astro/test/fixtures/astro-assets-prefix/src/assets/ペンギン.jpg
vendored
Normal file
BIN
packages/astro/test/fixtures/astro-assets-prefix/src/assets/ペンギン.jpg
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 11 KiB |
|
@ -3,3 +3,5 @@
|
|||
Relative image has assetsPrefix
|
||||
|
||||
![Relative image](../assets/penguin1.jpg)
|
||||
|
||||
![non-UTF-8 file name image](../assets/ペンギン.jpg)
|
||||
|
|
|
@ -11,6 +11,8 @@ export function rehypeImages() {
|
|||
if (node.tagName !== 'img') return;
|
||||
|
||||
if (node.properties?.src) {
|
||||
node.properties.src = decodeURI(node.properties.src);
|
||||
|
||||
if (file.data.imagePaths?.has(node.properties.src)) {
|
||||
const { ...props } = node.properties;
|
||||
|
||||
|
|
Loading…
Reference in a new issue