Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline (Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/* packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
80 lines
1.7 KiB
TypeScript
80 lines
1.7 KiB
TypeScript
function normalizeWorkspacePathOld(value: string): string {
|
|
const normalized = value.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
const segments = normalized.split("/").filter(Boolean);
|
|
if (segments.some((segment) => segment === "." || segment === "..")) {
|
|
throw new Error("Path escapes the computer workspace");
|
|
}
|
|
return segments.join("/");
|
|
}
|
|
|
|
function normalizeWorkspacePathNew(value: string): string {
|
|
const normalized = value.replace(/\\/g, "/").replace(/^\/+/, "");
|
|
const rawSegments = normalized.split("/").filter(Boolean);
|
|
if (rawSegments.some((segment) => segment === "..")) {
|
|
throw new Error("Path escapes the computer workspace");
|
|
}
|
|
const segments = rawSegments.filter((segment) => segment !== ".");
|
|
return segments.join("/");
|
|
}
|
|
|
|
console.log(
|
|
"Old '.' ->",
|
|
(() => {
|
|
try {
|
|
return normalizeWorkspacePathOld(".");
|
|
} catch (e) {
|
|
return e.message;
|
|
}
|
|
})(),
|
|
);
|
|
console.log(
|
|
"New '.' ->",
|
|
(() => {
|
|
try {
|
|
return normalizeWorkspacePathNew(".");
|
|
} catch (e) {
|
|
return e.message;
|
|
}
|
|
})(),
|
|
);
|
|
console.log(
|
|
"New './apex-trading' ->",
|
|
(() => {
|
|
try {
|
|
return normalizeWorkspacePathNew("./apex-trading");
|
|
} catch (e) {
|
|
return e.message;
|
|
}
|
|
})(),
|
|
);
|
|
console.log(
|
|
"New '..' ->",
|
|
(() => {
|
|
try {
|
|
return normalizeWorkspacePathNew("..");
|
|
} catch (e) {
|
|
return e.message;
|
|
}
|
|
})(),
|
|
);
|
|
console.log(
|
|
"New '../foo' ->",
|
|
(() => {
|
|
try {
|
|
return normalizeWorkspacePathNew("../foo");
|
|
} catch (e) {
|
|
return e.message;
|
|
}
|
|
})(),
|
|
);
|
|
console.log(
|
|
"New 'foo/bar' ->",
|
|
(() => {
|
|
try {
|
|
return normalizeWorkspacePathNew("foo/bar");
|
|
} catch (e) {
|
|
return e.message;
|
|
}
|
|
})(),
|
|
);
|