mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-07 15:52:52 +03:00
fix(electron): sanitize staged bundle paths cross-platform
Match both slash styles when removing build-machine paths from the staged standalone bundle so the sanitization step works on Windows and POSIX builds. While touching the helper, replace the custom basename logic with Node's built-in `path.basename` for clarity.
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user