Skip to content
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

fix: encodeURI for passthrough aliases #3346

Merged
merged 1 commit into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion src/TemplatePassthroughManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class TemplatePassthroughManager {
for (let entry of result) {
for (let src in entry.map) {
let dest = TemplatePath.stripLeadingSubPath(entry.map[src], this.outputDir);
entries["/" + dest] = src;
entries["/" + encodeURI(dest)] = src;
}
}
return entries;
Expand Down
20 changes: 19 additions & 1 deletion test/TemplatePassthroughManagerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import FileSystemSearch from "../src/FileSystemSearch.js";
import EleventyFiles from "../src/EleventyFiles.js";
import EleventyExtensionMap from "../src/EleventyExtensionMap.js";

import { getTemplateConfigInstanceCustomCallback } from "./_testHelpers.js";
import { getTemplateConfigInstance, getTemplateConfigInstanceCustomCallback } from "./_testHelpers.js";

test("Get paths from Config", async (t) => {
let eleventyConfig = new TemplateConfig();
Expand Down Expand Up @@ -188,6 +188,24 @@ test("getAllNormalizedPaths with globs", async (t) => {
]);
});

test("getAliasesFromPassthroughResults with Unicode filenames", async (t) => {
let eleventyConfig = await getTemplateConfigInstance();

let mgr = new TemplatePassthroughManager(eleventyConfig);
let results = [
{ map: { "./path/file": "_site/path/file" } },
{ map: { "./测试.用例/⌘": "_site/测试.用例/⌘" } },
{ map: { "./path/测试.用例": "_site/path/测试.用例" } },
{ map: { "./测试.用例/file": "_site/测试.用例/file" } },
]
t.deepEqual(mgr.getAliasesFromPassthroughResults(results), {
"/path/file": "./path/file",
"/%E6%B5%8B%E8%AF%95.%E7%94%A8%E4%BE%8B/%E2%8C%98": "./测试.用例/⌘",
"/path/%E6%B5%8B%E8%AF%95.%E7%94%A8%E4%BE%8B": "./path/测试.用例",
"/%E6%B5%8B%E8%AF%95.%E7%94%A8%E4%BE%8B/file": "./测试.用例/file",
});
});

test("Look for uniqueness on template passthrough paths #1677", async (t) => {
let formats = [];

Expand Down