Skip to content
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions src/compiler/SyncerPageCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -887,10 +887,12 @@
name = "";
}

const blobMarkdown = `![[${blobFullPath}${name}]]`;
// Convert the path to Quartz format with /img/user/ prefix
const quartzImagePath = `/img/user/${blobFullPath.replace(/ /g, '%20')}`;

Check failure on line 891 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 891 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 891 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 891 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 891 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`
const blobMarkdown = `![${blobName}${name}](${quartzImagePath})`;

assets.push({
path: blobFullPath,
path: quartzImagePath,
content: blobBase64,
});

Expand Down Expand Up @@ -952,10 +954,12 @@
this.settings.vaultPath,
)?.path ?? blobPath;

const blobMarkdown = `![${blobName}](${blobFullPath})`;
// Convert the path to Quartz format with /img/user/ prefix
const quartzImagePath = `/img/user/${blobFullPath.replace(/ /g, '%20')}`;

Check failure on line 958 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 958 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 958 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 958 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 958 in src/compiler/SyncerPageCompiler.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`
const blobMarkdown = `![${blobName}](${quartzImagePath})`;

assets.push({
path: blobFullPath,
path: quartzImagePath,
content: blobBase64,
});

Expand Down
39 changes: 39 additions & 0 deletions src/test/assetPathTransform.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { describe, it, expect } from "@jest/globals";

describe("Asset Path Transformation", () => {
it("should encode spaces in asset paths correctly", () => {
// Test the logic used in SyncerPageCompiler
const testPaths = [
"A Assets/travolta.webp",
"z_assets/albert_dente.webp",

Check failure on line 8 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`

Check failure on line 8 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`

Check failure on line 8 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`

Check failure on line 8 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`

Check failure on line 8 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`
"My Images/test image.png",
"simple.jpg"

Check failure on line 10 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`

Check failure on line 10 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`

Check failure on line 10 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`

Check failure on line 10 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`

Check failure on line 10 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`
];

Check failure on line 12 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`

Check failure on line 12 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`

Check failure on line 12 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`

Check failure on line 12 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`

Check failure on line 12 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`
const expectedPaths = [
"/img/user/A%20Assets/travolta.webp",
"/img/user/z_assets/albert_dente.webp",
"/img/user/My%20Images/test%20image.png",

Check failure on line 16 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`

Check failure on line 16 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`

Check failure on line 16 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`

Check failure on line 16 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`

Check failure on line 16 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `·`
"/img/user/simple.jpg"

Check failure on line 17 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`

Check failure on line 17 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`

Check failure on line 17 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`

Check failure on line 17 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`

Check failure on line 17 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Insert `,`
];

Check failure on line 19 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`

Check failure on line 19 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`

Check failure on line 19 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`

Check failure on line 19 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`

Check failure on line 19 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Delete `↹↹`
testPaths.forEach((path, index) => {
const quartzPath = `/img/user/${path.replace(/ /g, '%20')}`;

Check failure on line 21 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 21 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 21 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 21 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`

Check failure on line 21 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `'%20'` with `"%20"`
expect(quartzPath).toBe(expectedPaths[index]);
});
});

it("should handle assets with special characters", () => {
// Test edge cases that might be encountered
const testCases = [
{ path: "assets/file with spaces.png", expected: "/img/user/assets/file%20with%20spaces.png" },

Check failure on line 29 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `·path:·"assets/file·with·spaces.png",·expected:·"/img/user/assets/file%20with%20spaces.png"·` with `⏎↹↹↹↹path:·"assets/file·with·spaces.png",⏎↹↹↹↹expected:·"/img/user/assets/file%20with%20spaces.png",⏎↹↹↹`

Check failure on line 29 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `·path:·"assets/file·with·spaces.png",·expected:·"/img/user/assets/file%20with%20spaces.png"·` with `⏎↹↹↹↹path:·"assets/file·with·spaces.png",⏎↹↹↹↹expected:·"/img/user/assets/file%20with%20spaces.png",⏎↹↹↹`

Check failure on line 29 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `·path:·"assets/file·with·spaces.png",·expected:·"/img/user/assets/file%20with%20spaces.png"·` with `⏎↹↹↹↹path:·"assets/file·with·spaces.png",⏎↹↹↹↹expected:·"/img/user/assets/file%20with%20spaces.png",⏎↹↹↹`

Check failure on line 29 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `·path:·"assets/file·with·spaces.png",·expected:·"/img/user/assets/file%20with%20spaces.png"·` with `⏎↹↹↹↹path:·"assets/file·with·spaces.png",⏎↹↹↹↹expected:·"/img/user/assets/file%20with%20spaces.png",⏎↹↹↹`

Check failure on line 29 in src/test/assetPathTransform.test.ts

View workflow job for this annotation

GitHub Actions / lint-and-check-formatting

Replace `·path:·"assets/file·with·spaces.png",·expected:·"/img/user/assets/file%20with%20spaces.png"·` with `⏎↹↹↹↹path:·"assets/file·with·spaces.png",⏎↹↹↹↹expected:·"/img/user/assets/file%20with%20spaces.png",⏎↹↹↹`
{ path: "folder/no-spaces.jpg", expected: "/img/user/folder/no-spaces.jpg" },
{ path: "multiple spaces.gif", expected: "/img/user/multiple%20%20spaces.gif" }
];

testCases.forEach(({ path, expected }) => {
const quartzPath = `/img/user/${path.replace(/ /g, '%20')}`;
expect(quartzPath).toBe(expected);
});
});
});