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 @@ -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" } ,
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