jebin2's picture
download
raw
1.96 kB
/**
* Live test for the openFileDialog comma-split bug using Electrobun.Utils directly.
*
* Steps:
* 1. Creates a temp file named "test, comma, file.txt" in ~/Downloads
* 2. Opens the real native file dialog via Electrobun.Utils.openFileDialog
* 3. Select that file in the dialog
* 4. Shows the raw split result (buggy) vs the correct path
*
* Run with:
* bun run electrobun-comma-path-bug/live.ts
*/
import Electrobun from "electrobun/bun";
import { writeFile, rm } from "fs/promises";
import { join } from "path";
import { homedir } from "os";
const TEST_FILE = join(homedir(), "Downloads", "test, comma, file.txt");
await writeFile(TEST_FILE, "electrobun openFileDialog comma bug test file");
console.log(`\nCreated test file: ${TEST_FILE}`);
console.log("─".repeat(60));
console.log("A file dialog will open.");
console.log(`Please navigate to ~/Downloads and select: test, comma, file.txt`);
console.log("─".repeat(60) + "\n");
const paths = await Electrobun.Utils.openFileDialog({
startingFolder: join(homedir(), "Downloads"),
canChooseFiles: true,
canChooseDirectory: false,
allowsMultipleSelection: false,
});
console.log("─".repeat(60));
console.log("Result from Electrobun.Utils.openFileDialog:");
console.log(" paths array :", JSON.stringify(paths));
console.log(" length :", paths.length);
console.log();
const expected = TEST_FILE;
const got = paths[0];
if (got === expected) {
console.log("✅ PASS — path returned correctly");
} else {
console.log("❌ FAIL — path is broken due to split(',')");
console.log(" Expected :", expected);
console.log(" Got :", got);
console.log();
console.log(" The filename contains commas, so split(',') fragmented it:");
paths.forEach((p, i) => console.log(` [${i}] "${p}"`));
console.log();
console.log(" Fix: use '\\0' (null byte) as the native delimiter instead of ','");
}
await rm(TEST_FILE, { force: true });

Xet Storage Details

Size:
1.96 kB
·
Xet hash:
6c5fc978ca39b6dfa1f69db86410e552af91b0cb5934e76b7589a5b232db8cc2

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.