File tree Expand file tree Collapse file tree 2 files changed +27
-1
lines changed
Expand file tree Collapse file tree 2 files changed +27
-1
lines changed Original file line number Diff line number Diff 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" } ,
Original file line number Diff line number Diff 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 ] > ;
You can’t perform that action at this time.
0 commit comments