Closed
Description
Importing a package into a package with a shorter package name that is simultaneously a prefix caused namespace removal to fail.
Original function:
if (config.no_namespace) {
return removeRootParentName(name, packages.find(p => name.startsWith(p))).replace(/\./g, '');
}
Proposed fix:
if (config.no_namespace) {
// Create a copy of the original array. Sort the array copy by length, from longest to shortest.
const sortedPackages = packages.map(p => p).sort((a, b) => b.length - a.length);
// Return the new package name with longest possible match removed from the name.
return removeRootParentName(name, sortedPackages.find(p => name.startsWith(p))).replace(/\./g, '');
}
Metadata
Metadata
Assignees
Labels
No labels