Skip to content

Commit 50cb744

Browse files
authored
fix: resolve strict dirs before suffixes for potential metadata files (#1480)
* fix: resolve strict dirs before suffixes for potential metadata files * fix: do not reuse suffixType if no match
1 parent fa58e77 commit 50cb744

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/resolve/metadataResolver.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,13 +376,8 @@ const parseAsContentMetadataXml =
376376
const matchesSuffixType = fsPath.split(sep).includes(suffixType.directoryName);
377377
if (matchesSuffixType) return matchesSuffixType;
378378

379-
// it might be a type that requires strict parent folder name.
380-
const strictFolderSuffixType = registry
381-
.getStrictFolderTypes()
382-
.find((l) => l.suffix === suffixType.suffix && l.directoryName && l.name !== suffixType.name);
383-
if (!strictFolderSuffixType) return false;
384-
385-
return fsPath.split(sep).includes(strictFolderSuffixType.directoryName);
379+
// at this point, the suffixType is not a match, so check for strict folder types
380+
return !!resolveTypeFromStrictFolder(registry)(fsPath);
386381
};
387382

388383
/**

test/resolve/metadataResolver.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,29 @@ describe('MetadataResolver', () => {
476476
expect(mdResolver.getComponentsFromPath(nonMetadataDirPath, filter)).to.deep.equal([]);
477477
});
478478

479+
it('Should resolve RestrictionRules metadata in mdapi format', () => {
480+
const unpackagedPath = 'unpackaged';
481+
const packageXmlPath = join(unpackagedPath, 'package.xml');
482+
const restrictionRulesPath = join('unpackaged', 'restrictionRules');
483+
const restrictionRulePath = join(restrictionRulesPath, 'Foo.rule');
484+
const treeContainer = VirtualTreeContainer.fromFilePaths([
485+
unpackagedPath,
486+
packageXmlPath,
487+
restrictionRulesPath,
488+
restrictionRulePath,
489+
]);
490+
const restrictionRuleComponent = new SourceComponent(
491+
{
492+
name: 'Foo',
493+
type: registry.types.restrictionrule,
494+
xml: restrictionRulePath,
495+
},
496+
treeContainer
497+
);
498+
const mdResolver = new MetadataResolver(undefined, treeContainer, false);
499+
expect(mdResolver.getComponentsFromPath(unpackagedPath)).to.deep.equal([restrictionRuleComponent]);
500+
});
501+
479502
it('Should not return a component if path to folder metadata xml is forceignored', () => {
480503
const path = xmlInFolder.FOLDER_XML_PATH;
481504
const access = testUtil.createMetadataResolver([

0 commit comments

Comments
 (0)