Skip to content

Commit fc27201

Browse files
committed
Allow wildcards in other protocols than file:// as well
1 parent 34d11a0 commit fc27201

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/Directory.Build.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>4.1.6</Version>
3+
<Version>4.1.7</Version>
44
<Authors>Martin Danielsson</Authors>
55
<Company>Haufe-Lexware GmbH &amp; Co. KG</Company>
66
<Description>Extensible, simple and fast ETL Tool</Description>
@@ -15,4 +15,3 @@
1515
<OutputPath>$(SolutionDir)bin\Release\</OutputPath>
1616
</PropertyGroup>
1717
</Project>
18-

src/NoFrillsTransformation/Program.cs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)