Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ private HashSet<string> MakeFilePathsRelative(ILogger logger, DirectoryInfo root
relativePath = "/" + relativePath;
}

relativePath = Uri.UnescapeDataString(relativePath);
relativePathSet.Add(relativePath);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,41 @@ public DefaultGraphTranslationServiceTests()
this.sourceDirectory.Create();
}

[TestMethod]
public void UnescapeComponentLocations()
{
// Arrange
var projectPath = "/my project/my project.csproj";

var singleFileComponentRecorder = this.componentRecorder.CreateSingleFileComponentRecorder(Path.Join(this.sourceDirectory.FullName, projectPath));
var processingResult = new DetectorProcessingResult
{
ResultCode = ProcessingResultCode.Success,
ContainersDetailsMap = new Dictionary<int, ContainerDetails>
{
{
this.sampleContainerDetails.Id, this.sampleContainerDetails
},
},
ComponentRecorders = [(this.componentDetectorMock.Object, this.componentRecorder)],
};

var detectedComponent = new DetectedComponent(new NuGetComponent("nugetComponent", "4.5.6"));
singleFileComponentRecorder.RegisterUsage(detectedComponent);

var settings = new ScanSettings { SourceDirectory = this.sourceDirectory };

// Act
var result = this.serviceUnderTest.GenerateScanResultFromProcessingResult(processingResult, settings);

// Assert
result.Should().NotBeNull();
result.ComponentsFound.Should().ContainSingle();

var resultComponent = result.ComponentsFound.Single();
resultComponent.LocationsFoundAt.Should().BeEquivalentTo([projectPath]);
}

[TestMethod]
public void GenerateScanResultFromResult_WithCustomLocations()
{
Expand Down