@@ -1179,13 +1179,20 @@ private static bool IsExperimentalFeatureEnabled(PSCmdlet psCmdlet, string featu
11791179 }
11801180
11811181 string jsonContent = File . ReadAllText ( configPath ) ;
1182+ var config = Newtonsoft . Json . Linq . JObject . Parse ( jsonContent ) ;
11821183
1183- // Parse JSON to check for experimental features
11841184 // Look for "ExperimentalFeatures": ["FeatureName"] in the config
1185- if ( jsonContent . Contains ( $ "\" { featureName } \" ") )
1185+ var experimentalFeatures = config [ "ExperimentalFeatures" ] as Newtonsoft . Json . Linq . JArray ;
1186+ if ( experimentalFeatures != null )
11861187 {
1187- psCmdlet . WriteVerbose ( string . Format ( "Experimental feature '{0}' found in configuration file" , featureName ) ) ;
1188- return true ;
1188+ foreach ( var feature in experimentalFeatures )
1189+ {
1190+ if ( string . Equals ( feature . ToString ( ) , featureName , StringComparison . OrdinalIgnoreCase ) )
1191+ {
1192+ psCmdlet . WriteVerbose ( string . Format ( "Experimental feature '{0}' found in configuration file" , featureName ) ) ;
1193+ return true ;
1194+ }
1195+ }
11891196 }
11901197
11911198 psCmdlet . WriteVerbose ( string . Format ( "Experimental feature '{0}' not found in configuration file" , featureName ) ) ;
@@ -1229,27 +1236,14 @@ private static string GetPSUserContentPath(PSCmdlet psCmdlet)
12291236 }
12301237
12311238 string jsonContent = File . ReadAllText ( configPath ) ;
1239+ var config = Newtonsoft . Json . Linq . JObject . Parse ( jsonContent ) ;
12321240
1233- // Simple JSON parsing to find PSUserContentPath
1234- // Format: "PSUserContentPath": "C:\\CustomPath"
1235- int userPathIndex = jsonContent . IndexOf ( "\" PSUserContentPath\" " , StringComparison . OrdinalIgnoreCase ) ;
1236- if ( userPathIndex >= 0 )
1241+ // Look for PSUserContentPath in the config
1242+ var psUserContentPath = config [ "PSUserContentPath" ] ? . ToString ( ) ;
1243+ if ( ! string . IsNullOrEmpty ( psUserContentPath ) )
12371244 {
1238- int colonIndex = jsonContent . IndexOf ( ':' , userPathIndex ) ;
1239- if ( colonIndex >= 0 )
1240- {
1241- int firstQuote = jsonContent . IndexOf ( '"' , colonIndex + 1 ) ;
1242- int secondQuote = jsonContent . IndexOf ( '"' , firstQuote + 1 ) ;
1243-
1244- if ( firstQuote >= 0 && secondQuote > firstQuote )
1245- {
1246- string customPath = jsonContent . Substring ( firstQuote + 1 , secondQuote - firstQuote - 1 ) ;
1247- // Unescape JSON string (handle \\)
1248- customPath = customPath . Replace ( "\\ \\ " , "\\ " ) ;
1249- psCmdlet . WriteVerbose ( string . Format ( "Found PSUserContentPath in config file: {0}" , customPath ) ) ;
1250- return customPath ;
1251- }
1252- }
1245+ psCmdlet . WriteVerbose ( string . Format ( "Found PSUserContentPath in config file: {0}" , psUserContentPath ) ) ;
1246+ return psUserContentPath ;
12531247 }
12541248
12551249 psCmdlet . WriteVerbose ( "PSUserContentPath not configured in PowerShell configuration file or environment variable" ) ;
0 commit comments