Skip to content

Commit 37589e6

Browse files
committed
fix: normalize system project paths in stripSystemDefaults
1 parent 6990dd1 commit 37589e6

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/node/config.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,32 @@ describe("Config", () => {
536536
expect(projectPaths).not.toContain("/sys/project");
537537
});
538538

539+
it("system project paths are normalized before stripping", async () => {
540+
writeSystemConfig({
541+
projects: [["/sys/project/", { workspaces: [] }]],
542+
});
543+
writeUserConfig({
544+
projects: [],
545+
});
546+
547+
const loaded = config.loadConfigOrDefault();
548+
// Normalized path (no trailing slash) should be in the loaded config
549+
expect(loaded.projects.has("/sys/project")).toBe(true);
550+
551+
await config.saveConfig(loaded);
552+
553+
const savedRaw = JSON.parse(
554+
fs.readFileSync(path.join(tempDir, "config.json"), "utf-8")
555+
) as Record<string, unknown>;
556+
// System project should be stripped despite trailing slash mismatch
557+
const savedProjects = savedRaw.projects as Array<[string, unknown]> | undefined;
558+
if (savedProjects) {
559+
const projectPaths = savedProjects.map(([p]) => p);
560+
expect(projectPaths).not.toContain("/sys/project");
561+
expect(projectPaths).not.toContain("/sys/project/");
562+
}
563+
});
564+
539565
it("system object defaults are stripped key-by-key on save", async () => {
540566
writeSystemConfig({
541567
featureFlagOverrides: { flagA: "on", flagB: "off" },

src/node/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ export class Config {
427427
for (const entry of systemConfig.projects) {
428428
if (Array.isArray(entry) && entry.length >= 2 && typeof entry[0] === "string") {
429429
const [projectPath, projectConfig] = entry;
430-
systemProjectMap.set(projectPath, JSON.stringify(projectConfig));
430+
systemProjectMap.set(stripTrailingSlashes(projectPath), JSON.stringify(projectConfig));
431431
}
432432
}
433433
const dataProjects = data.projects as Array<[string, unknown]>;

0 commit comments

Comments
 (0)