@@ -283,11 +283,18 @@ private static void ReadSources(Context context, ConfigFileXml configFile, Reade
283283
284284 private static void AddSources ( Context context , ReaderFactory readerFactory , List < ISourceReader > sourceList , HashSet < string > sourceFiles , SourceTargetXml thisSource )
285285 {
286- // Wildcards in Source?
287- if ( thisSource . Uri . StartsWith ( "file://" )
286+ // Wildcards in Source? Heuristic to determine if we have a file-based source with wildcards.
287+ if ( ( thisSource . Uri . Contains ( "file" ) || thisSource . Uri . Contains ( "xml" ) || thisSource . Uri . Contains ( "json" ) )
288288 && ( thisSource . Uri . Contains ( "*" ) || thisSource . Uri . Contains ( "?" ) ) )
289289 {
290- string sourceFile = thisSource . Uri . Substring ( 7 ) ; // strip file://
290+ // Extract protocol (everything up to and including "://")
291+ int protocolEndIndex = thisSource . Uri . IndexOf ( "://" ) ;
292+ if ( protocolEndIndex < 0 )
293+ throw new InvalidOperationException ( "No protocol found in URI with wildcards: " + thisSource . Uri ) ;
294+
295+ string protocol = thisSource . Uri . Substring ( 0 , protocolEndIndex + 3 ) ; // Include "://"
296+ string sourceFile = thisSource . Uri . Substring ( protocolEndIndex + 3 ) ; // Strip protocol
297+
291298 context . Logger . Info ( "Detected wildcards in file name (" + sourceFile + ")." ) ;
292299 string ? path = Path . GetDirectoryName ( sourceFile ) ;
293300 if ( string . IsNullOrWhiteSpace ( path ) )
@@ -299,7 +306,7 @@ private static void AddSources(Context context, ReaderFactory readerFactory, Lis
299306 if ( sourceFiles . Contains ( sourceFileName ) )
300307 continue ;
301308 context . Logger . Info ( "Creating reader for: " + sourceFileName ) ;
302- sourceList . Add ( readerFactory . CreateReader ( context , "file://" + sourceFileName , thisSource . Config ) ) ;
309+ sourceList . Add ( readerFactory . CreateReader ( context , protocol + sourceFileName , thisSource . Config ) ) ;
303310 sourceFiles . Add ( sourceFileName ) ;
304311 }
305312 }
0 commit comments