Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
3 changes: 1 addition & 2 deletions src/resolve/metadataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,8 @@ const parseAsFolderMetadataXml =
if (parts.length > 1) {
const folderContentTypesDirs = getFolderContentTypeDirNames(registry);
// check if the path contains a folder content name as a directory
// e.g., `/reports/` and if it does return that folder name.
folderContentTypesDirs.some((dirName) => {
if (fsPath.includes(`${sep}${dirName}${sep}`)) {
if (parts.includes(dirName)) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Do you need to have this be parts.slice(0, -1) so that it excludes the final part of the path and therefore guarantees that it's a folder that's being matched and not a file?

Copy link
Copy Markdown
Collaborator Author

@ravipanguluri ravipanguluri Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right about this. I'll quickly test this out though. Although, this would only really get hit if the file was named exactly the same thing as the dirName with no file extension, which seems pretty unlikely.

folderName = dirName;
}
});
Expand Down
25 changes: 25 additions & 0 deletions test/resolve/metadataResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,31 @@ describe('MetadataResolver', () => {
expect(comp[0]).to.have.deep.property('type', registryAccess.getTypeByName('ReportFolder'));
});

it('should resolve folder metadata and reports from zip paths without leading directory', () => {
const registryAccess = new RegistryAccess();
const reportFolderDir = 'reports';
const reportSubFolder = join(reportFolderDir, 'TestFolder');
const virtualFS: VirtualDirectory[] = [
{ dirPath: reportFolderDir, children: ['TestFolder-meta.xml', 'TestFolder'] },
{ dirPath: reportSubFolder, children: ['MyReport.report-meta.xml'] },
];
const tree = new VirtualTreeContainer(virtualFS);
const mdResolver = new MetadataResolver(registryAccess, tree);

const components = mdResolver.getComponentsFromPath(reportFolderDir);
expect(components).to.be.an('array').with.lengthOf(2);

const folderComp = components.find((c) => c.type.name === 'ReportFolder');
expect(folderComp).to.exist;
expect(folderComp).to.have.property('name', 'TestFolder');
expect(folderComp).to.have.deep.property('type', registryAccess.getTypeByName('ReportFolder'));

const reportComp = components.find((c) => c.type.name === 'Report');
expect(reportComp).to.exist;
expect(reportComp).to.have.property('name', 'TestFolder/MyReport');
expect(reportComp).to.have.deep.property('type', registryAccess.getTypeByName('Report'));
});

it('Should not mistake folder component of a mixed content type as that type', () => {
// this test has coveage on non-mixedContent types as well by nature of the execution path
const path = mixedContentInFolder.FOLDER_XML_PATH;
Expand Down
Loading