Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(electron): sanitize staged bundle paths cross-platform

Kfir Amare06e7157ac79
diff --git a/scripts/prepare-electron-standalone.mjs b/scripts/prepare-electron-standalone.mjs
index 4d26be012b..4f8c5e5d11 100644
--- a/scripts/prepare-electron-standalone.mjs
+++ b/scripts/prepare-electron-standalone.mjs
@@ -9,7 +9,7 @@ import {
rmSync,
writeFileSync,
} from "node:fs";
-import { dirname, join, relative } from "node:path";
+import { basename, dirname, join, relative } from "node:path";
import { fileURLToPath } from "node:url";
const __filename = fileURLToPath(import.meta.url);
@@ -45,8 +45,11 @@ function resolveStandaloneBundleDir() {
);
}
-function basename(filePath) {
- return filePath.split(/[\\/]/).filter(Boolean).at(-1) || filePath;
+function createPathPattern(filePath) {
+ return filePath
+ .replace(/\\/g, "/")
+ .replace(/[.*+?^${}()|[\]\\]/g, "\\$&")
+ .replace(/\//g, "[\\\\/]");
}
function sanitizeBuildPaths(bundleDir) {
@@ -65,8 +68,7 @@ function sanitizeBuildPaths(bundleDir) {
let updated = content;
for (const original of replacements) {
- const escaped = original.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
- updated = updated.replace(new RegExp(escaped, "g"), ".");
+ updated = updated.replace(new RegExp(createPathPattern(original), "g"), ".");
}
if (updated !== content) {