Skip to content

Commit e3bb40f

Browse files
Copilotphilnach
andcommitted
Remove redundant handling of leading slashes
Co-authored-by: philnach <[email protected]>
1 parent aa56004 commit e3bb40f

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension.UnitTests/CosmosDataSinkExtensionTests.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -481,27 +481,5 @@ public void GetPropertyValue_WithNullIntermediateValue_ReturnsNull()
481481
// Assert
482482
Assert.IsNull(result);
483483
}
484-
485-
[TestMethod]
486-
public void GetPropertyValue_WithLeadingSlash_WorksCorrectly()
487-
{
488-
// Arrange - Test that paths with leading slash work (defensive programming)
489-
var expando = new ExpandoObject();
490-
var dict = (IDictionary<string, object?>)expando;
491-
dict["id"] = "test-id";
492-
493-
var nestedExpando = new ExpandoObject();
494-
var nestedDict = (IDictionary<string, object?>)nestedExpando;
495-
nestedDict["partitionkey"] = "pk-value";
496-
497-
dict["parent"] = nestedExpando;
498-
499-
// Act - Path with leading slash (though TrimStart is called in actual code)
500-
var result = InvokeGetPropertyValue(expando, "/parent/partitionkey");
501-
502-
// Assert
503-
Assert.IsNotNull(result);
504-
Assert.AreEqual("pk-value", result);
505-
}
506484
}
507485
}

Extensions/Cosmos/Cosmos.DataTransfer.CosmosExtension/CosmosDataSinkExtension.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@ private static MemoryStream CreateItemStream(ExpandoObject item)
287287
private static string? GetPropertyValue(ExpandoObject item, string propertyName)
288288
{
289289
// Handle nested property paths (e.g., "property1/property2/property3")
290-
// Split and remove empty entries to handle paths starting with '/' (e.g., "/property/nested")
291-
var pathSegments = propertyName.Split('/', StringSplitOptions.RemoveEmptyEntries);
290+
// Note: Calling code uses TrimStart('/') to remove leading slash before calling this method
291+
var pathSegments = propertyName.Split('/');
292292
object? current = item;
293293

294294
foreach (var segment in pathSegments)

0 commit comments

Comments
 (0)