@smithy/shared-ini-file-loader 2.2.6 → 2.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,14 +5,15 @@ const types_1 = require("@smithy/types");
5
5
  const loadSharedConfigFiles_1 = require("./loadSharedConfigFiles");
6
6
  const getConfigData = (data) => Object.entries(data)
7
7
  .filter(([key]) => {
8
- const sections = key.split(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR);
9
- if (sections.length === 2 && Object.values(types_1.IniSectionType).includes(sections[0])) {
10
- return true;
8
+ const indexOfSeparator = key.indexOf(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR);
9
+ if (indexOfSeparator === -1) {
10
+ return false;
11
11
  }
12
- return false;
12
+ return Object.values(types_1.IniSectionType).includes(key.substring(0, indexOfSeparator));
13
13
  })
14
14
  .reduce((acc, [key, value]) => {
15
- const updatedKey = key.startsWith(types_1.IniSectionType.PROFILE) ? key.split(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR)[1] : key;
15
+ const indexOfSeparator = key.indexOf(loadSharedConfigFiles_1.CONFIG_PREFIX_SEPARATOR);
16
+ const updatedKey = key.substring(0, indexOfSeparator) === types_1.IniSectionType.PROFILE ? key.substring(indexOfSeparator + 1) : key;
16
17
  acc[updatedKey] = value;
17
18
  return acc;
18
19
  }, {
@@ -2,14 +2,15 @@ import { IniSectionType } from "@smithy/types";
2
2
  import { CONFIG_PREFIX_SEPARATOR } from "./loadSharedConfigFiles";
3
3
  export const getConfigData = (data) => Object.entries(data)
4
4
  .filter(([key]) => {
5
- const sections = key.split(CONFIG_PREFIX_SEPARATOR);
6
- if (sections.length === 2 && Object.values(IniSectionType).includes(sections[0])) {
7
- return true;
5
+ const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
6
+ if (indexOfSeparator === -1) {
7
+ return false;
8
8
  }
9
- return false;
9
+ return Object.values(IniSectionType).includes(key.substring(0, indexOfSeparator));
10
10
  })
11
11
  .reduce((acc, [key, value]) => {
12
- const updatedKey = key.startsWith(IniSectionType.PROFILE) ? key.split(CONFIG_PREFIX_SEPARATOR)[1] : key;
12
+ const indexOfSeparator = key.indexOf(CONFIG_PREFIX_SEPARATOR);
13
+ const updatedKey = key.substring(0, indexOfSeparator) === IniSectionType.PROFILE ? key.substring(indexOfSeparator + 1) : key;
13
14
  acc[updatedKey] = value;
14
15
  return acc;
15
16
  }, {
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@smithy/shared-ini-file-loader",
3
- "version": "2.2.6",
3
+ "version": "2.2.8",
4
4
  "dependencies": {
5
- "@smithy/types": "^2.7.0",
5
+ "@smithy/types": "^2.8.0",
6
6
  "tslib": "^2.5.0"
7
7
  },
8
8
  "devDependencies": {