fix(runtime): avoid encoding latin1 directory headers

This commit is contained in:
Bohdan Triapitsyn
2026-06-24 00:43:03 +03:00
parent 37aec95f37
commit c3cf914fda
2 changed files with 11 additions and 7 deletions
+7 -1
View File
@@ -394,9 +394,15 @@ describe('runtimeFetch header sanitization', () => {
expect(result).toBeFalsy();
});
test('sanitizeHeadersForBrowser always encodes directory hints with marker', () => {
test('sanitizeHeadersForBrowser leaves Latin-1 directory hints unchanged', () => {
const path = 'C:\\work\\foo%20bar';
const result = sanitizeHeadersForBrowser({ 'x-opencode-directory': path });
expect(result).toBeFalsy();
});
test('sanitizeHeadersForBrowser encodes non-Latin-1 directory hints with marker', () => {
const path = 'D:\\文件夹';
const result = sanitizeHeadersForBrowser({ 'x-opencode-directory': path });
expect(result).toBeTruthy();
const encoded = Object.fromEntries(result!);
expect(encoded['x-opencode-directory']).toBe(encodeURIComponent(path));