Skip to content
Merged
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 @@ -139,15 +139,15 @@ describe("Dataset utils unit tests - function getExtensionMap", () => {
} as any;
}

it("should return extension map based on member names", async () => {
it("should not infer extensions from member names", async () => {
const mockNode = createMockNode("TEST.PDS", [{ label: "MEMBER1" }, { label: "COBOL" }, { label: "XML" }]);

const result = await DatasetUtils.getExtensionMap(mockNode, false);

expect(result).toEqual({
member1: "txt",
cobol: "cbl",
xml: "xml",
cobol: "txt",
xml: "txt",
});
});

Expand All @@ -158,7 +158,7 @@ describe("Dataset utils unit tests - function getExtensionMap", () => {

expect(result).toEqual({
MEMBER1: "txt",
COBOL: "cbl",
COBOL: "txt",
".f@K3": "txt",
});
});
Expand Down
30 changes: 1 addition & 29 deletions packages/zowe-explorer/src/trees/dataset/DatasetUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,39 +176,11 @@ export class DatasetUtils {
): Promise<{ [key: string]: string }> {
const extensionMap: { [key: string]: string } = {};
const children = await node.getChildren();
const extension = overrideExtension ?? DatasetUtils.getExtension(node.label as string) ?? ".txt";

for (const child of children) {
let extension;
let label = child.label as string;

if (overrideExtension) {
extension = overrideExtension;
} else {
for (const [ext, matches] of DS_EXTENSION_MAP.entries()) {
if (ext === ".c") {
// Special case for ".c" extension, skip the following logic
// As it's not unique enough and would otherwise match on anything containing "C"
// TODO: rrevisit later if this can be handled better while still allowing c files
continue;
}
if (matches.some((match) => (match instanceof RegExp ? match.test(label) : label.includes(match)))) {
extension = ext;
break;
}
}

// If no extension found, fall back to using the PDS name as extension
if (!extension) {
const parentExtension = DatasetUtils.getExtension(node.label as string);
if (parentExtension) {
extension = parentExtension;
} else {
// Use default extension if nothing else matches
extension = ".txt";
}
}
}

if (!uppercaseNames) {
label = label.toLowerCase();
}
Expand Down
Loading