diff --git a/packages/zowe-explorer/CHANGELOG.md b/packages/zowe-explorer/CHANGELOG.md index 7758d94bd..ad0feee44 100644 --- a/packages/zowe-explorer/CHANGELOG.md +++ b/packages/zowe-explorer/CHANGELOG.md @@ -9,6 +9,7 @@ All notable changes to the "vscode-extension-for-zowe" extension will be documen ### Bug fixes - Fixed an issue where opening sequential data sets within favorited searches resulted in an error. [#3163](https://github.com/zowe/zowe-explorer-vscode/pull/3163) +- Fixed an issue where automatic file extension detection identified file types incorrectly. [#3181](https://github.com/zowe/zowe-explorer-vscode/pull/3181) ## `3.0.0` diff --git a/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetUtils.unit.test.ts b/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetUtils.unit.test.ts index 7f79ff5e8..8fe99b035 100644 --- a/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetUtils.unit.test.ts +++ b/packages/zowe-explorer/__tests__/__unit__/trees/dataset/DatasetUtils.unit.test.ts @@ -34,6 +34,6 @@ describe("Dataset utils unit tests - function getExtension", () => { } }); it("returns null if no language was detected", () => { - expect(DatasetUtils.getExtension("TEST.DS")).toBe(null); + expect(DatasetUtils.getExtension("TEST.DS.X")).toBe(null); }); }); diff --git a/packages/zowe-explorer/src/trees/dataset/DatasetUtils.ts b/packages/zowe-explorer/src/trees/dataset/DatasetUtils.ts index 1483cf89a..73444e362 100644 --- a/packages/zowe-explorer/src/trees/dataset/DatasetUtils.ts +++ b/packages/zowe-explorer/src/trees/dataset/DatasetUtils.ts @@ -75,14 +75,8 @@ export class DatasetUtils { const split = bracket > -1 ? label.substring(0, bracket).split(".", limit) : label.split(".", limit); for (let i = split.length - 1; i > 0; i--) { for (const [ext, matches] of DS_EXTENSION_MAP.entries()) { - for (const match of matches) { - if (match instanceof RegExp) { - if (match.test(split[i])) { - return ext; - } - } else if (match.includes(split[i])) { - return ext; - } + if (matches.some((match) => (match instanceof RegExp ? match.test(split[i]) : match === split[i]))) { + return ext; } } }