@@ -8,6 +8,32 @@ namespace NServiceBus
8
8
9
9
class FileShareDataBusImplementation : IDataBus
10
10
{
11
+ // to account for mixed platforms ie windows -> linux or linux -> windows
12
+ internal class PathNormalizer
13
+ {
14
+ // Example keys
15
+ // string key1 = "foldername/filename";
16
+ // string key2 = "foldername\\filename";
17
+
18
+ // Normalize the keys
19
+ // string normalizedKey1 = NormalizePath(key1);
20
+ // string normalizedKey2 = NormalizePath(key2);
21
+
22
+ // Output the normalized keys
23
+ // Console.WriteLine(normalizedKey1); // Output will be "foldername\filename" on Windows, "foldername/filename" on Unix-based systems
24
+ // Console.WriteLine(normalizedKey2); // Output will be "foldername\filename" on Windows, "foldername/filename" on Unix-based systems
25
+ internal static string NormalizePath ( string key )
26
+ {
27
+ // Determine the directory separator for the current platform
28
+ char separator = Path . DirectorySeparatorChar ;
29
+ // Replace any forward slashes (common in URIs) and backward slashes with the platform-specific separator
30
+ string normalizedPath = key . Replace ( '/' , separator ) . Replace ( '\\ ' , separator ) ;
31
+
32
+ return normalizedPath ;
33
+ }
34
+ }
35
+
36
+
11
37
public FileShareDataBusImplementation ( string basePath )
12
38
{
13
39
this . basePath = basePath ;
@@ -17,7 +43,7 @@ public FileShareDataBusImplementation(string basePath)
17
43
18
44
public Task < Stream > Get ( string key )
19
45
{
20
- var filePath = Path . Combine ( basePath , key ) ;
46
+ var filePath = Path . Combine ( basePath , PathNormalizer . NormalizePath ( key ) ) ;
21
47
22
48
logger . DebugFormat ( "Opening stream from '{0}'." , filePath ) ;
23
49
0 commit comments