| /** | |
| * Live test for the openFileDialog comma-split bug. | |
| * | |
| * Run: electrobun dev | |
| * | |
| * The app opens a BrowserWindow, creates a test file with commas in the name, | |
| * then immediately opens the native file dialog. | |
| * Select "test, comma, file.txt" from ~/Downloads and watch the console output. | |
| */ | |
| import Electrobun, { BrowserWindow } 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); | |
| const win = new BrowserWindow({ | |
| title: "openFileDialog comma bug test", | |
| url: "data:text/html,<h2 style='font-family:monospace;padding:20px'>Select <b>test, comma, file.txt</b> from ~/Downloads</h2>", | |
| frame: { width: 500, height: 120 }, | |
| }); | |
| // Give the window a moment to appear before opening the dialog. | |
| await Bun.sleep(800); | |
| console.log("─".repeat(60)); | |
| console.log("File dialog opening — select: test, comma, file.txt"); | |
| console.log("─".repeat(60)); | |
| const paths = await Electrobun.Utils.openFileDialog({ | |
| startingFolder: join(homedir(), "Downloads"), | |
| canChooseFiles: true, | |
| canChooseDirectory: false, | |
| allowsMultipleSelection: false, | |
| }); | |
| console.log("\nResult from Electrobun.Utils.openFileDialog:"); | |
| console.log(" paths :", JSON.stringify(paths)); | |
| console.log(" length:", paths.length); | |
| console.log(); | |
| const expected = TEST_FILE; | |
| const got = paths[0]; | |
| if (got === expected) { | |
| console.log("✅ PASS — full path returned correctly"); | |
| } else { | |
| console.log("❌ FAIL — split(',') broke the path"); | |
| console.log(" Expected :", expected); | |
| console.log(" Got [0] :", got); | |
| console.log(); | |
| console.log(" All fragments returned:"); | |
| paths.forEach((p, i) => console.log(` [${i}] "${p}"`)); | |
| console.log(); | |
| console.log(" Fix: native side should join paths with \\0 (null byte),"); | |
| console.log(" and JS side should split on \\0 instead of ','."); | |
| } | |
| await rm(TEST_FILE, { force: true }); | |
| Electrobun.quit(); | |
Xet Storage Details
- Size:
- 2.15 kB
- Xet hash:
- 5d281cb3505806eac96697798a74de9e495bb00443bcd726ea3e5da11031b96e
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.