Skip to content

Commit 17ef993

Browse files
committed
fix: normalize system project paths in stripSystemDefaults
1 parent f57c301 commit 17ef993

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
@@ -516,6 +516,32 @@ describe("Config", () => {
516516
expect(projectPaths).not.toContain("/sys/project");
517517
});
518518

519+
it("system project paths are normalized before stripping", async () => {
520+
writeSystemConfig({
521+
projects: [["/sys/project/", { workspaces: [] }]],
522+
});
523+
writeUserConfig({
524+
projects: [],
525+
});
526+
527+
const loaded = config.loadConfigOrDefault();
528+
// Normalized path (no trailing slash) should be in the loaded config
529+
expect(loaded.projects.has("/sys/project")).toBe(true);
530+
531+
await config.saveConfig(loaded);
532+
533+
const savedRaw = JSON.parse(
534+
fs.readFileSync(path.join(tempDir, "config.json"), "utf-8")
535+
) as Record<string, unknown>;
536+
// System project should be stripped despite trailing slash mismatch
537+
const savedProjects = savedRaw.projects as Array<[string, unknown]> | undefined;
538+
if (savedProjects) {
539+
const projectPaths = savedProjects.map(([p]) => p);
540+
expect(projectPaths).not.toContain("/sys/project");
541+
expect(projectPaths).not.toContain("/sys/project/");
542+
}
543+
});
544+
519545
it("system object defaults are stripped key-by-key on save", async () => {
520546
writeSystemConfig({
521547
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)