@smithy/shared-ini-file-loader 2.0.11 → 2.0.13

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,10 +5,12 @@ const profileNameBlockList = ["__proto__", "profile __proto__"];
5
5
  const parseIni = (iniData) => {
6
6
  const map = {};
7
7
  let currentSection;
8
+ let currentSubSection;
8
9
  for (let line of iniData.split(/\r?\n/)) {
9
10
  line = line.split(/(^|\s)[;#]/)[0].trim();
10
11
  const isSection = line[0] === "[" && line[line.length - 1] === "]";
11
12
  if (isSection) {
13
+ currentSubSection = undefined;
12
14
  currentSection = line.substring(1, line.length - 1);
13
15
  if (profileNameBlockList.includes(currentSection)) {
14
16
  throw new Error(`Found invalid profile name "${currentSection}"`);
@@ -16,16 +18,18 @@ const parseIni = (iniData) => {
16
18
  }
17
19
  else if (currentSection) {
18
20
  const indexOfEqualsSign = line.indexOf("=");
19
- const start = 0;
20
- const end = line.length - 1;
21
- const isAssignment = indexOfEqualsSign !== -1 && indexOfEqualsSign !== start && indexOfEqualsSign !== end;
22
- if (isAssignment) {
21
+ if (![0, -1].includes(indexOfEqualsSign)) {
23
22
  const [name, value] = [
24
23
  line.substring(0, indexOfEqualsSign).trim(),
25
24
  line.substring(indexOfEqualsSign + 1).trim(),
26
25
  ];
27
- map[currentSection] = map[currentSection] || {};
28
- map[currentSection][name] = value;
26
+ if (value === "") {
27
+ currentSubSection = name;
28
+ }
29
+ else if (currentSubSection === undefined) {
30
+ map[currentSection] = map[currentSection] || {};
31
+ map[currentSection][name] = value;
32
+ }
29
33
  }
30
34
  }
31
35
  }
@@ -2,10 +2,12 @@ const profileNameBlockList = ["__proto__", "profile __proto__"];
2
2
  export const parseIni = (iniData) => {
3
3
  const map = {};
4
4
  let currentSection;
5
+ let currentSubSection;
5
6
  for (let line of iniData.split(/\r?\n/)) {
6
7
  line = line.split(/(^|\s)[;#]/)[0].trim();
7
8
  const isSection = line[0] === "[" && line[line.length - 1] === "]";
8
9
  if (isSection) {
10
+ currentSubSection = undefined;
9
11
  currentSection = line.substring(1, line.length - 1);
10
12
  if (profileNameBlockList.includes(currentSection)) {
11
13
  throw new Error(`Found invalid profile name "${currentSection}"`);
@@ -13,16 +15,18 @@ export const parseIni = (iniData) => {
13
15
  }
14
16
  else if (currentSection) {
15
17
  const indexOfEqualsSign = line.indexOf("=");
16
- const start = 0;
17
- const end = line.length - 1;
18
- const isAssignment = indexOfEqualsSign !== -1 && indexOfEqualsSign !== start && indexOfEqualsSign !== end;
19
- if (isAssignment) {
18
+ if (![0, -1].includes(indexOfEqualsSign)) {
20
19
  const [name, value] = [
21
20
  line.substring(0, indexOfEqualsSign).trim(),
22
21
  line.substring(indexOfEqualsSign + 1).trim(),
23
22
  ];
24
- map[currentSection] = map[currentSection] || {};
25
- map[currentSection][name] = value;
23
+ if (value === "") {
24
+ currentSubSection = name;
25
+ }
26
+ else if (currentSubSection === undefined) {
27
+ map[currentSection] = map[currentSection] || {};
28
+ map[currentSection][name] = value;
29
+ }
26
30
  }
27
31
  }
28
32
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@smithy/shared-ini-file-loader",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "dependencies": {
5
- "@smithy/types": "^2.3.3",
5
+ "@smithy/types": "^2.3.4",
6
6
  "tslib": "^2.5.0"
7
7
  },
8
8
  "devDependencies": {
@@ -10,23 +10,21 @@
10
10
  "@types/node": "^14.14.31",
11
11
  "concurrently": "7.0.0",
12
12
  "downlevel-dts": "0.10.1",
13
- "jest": "28.1.1",
14
13
  "rimraf": "3.0.2",
15
- "typedoc": "0.23.23",
16
- "typescript": "~4.9.5"
14
+ "typedoc": "0.23.23"
17
15
  },
18
16
  "scripts": {
19
17
  "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
20
- "build:cjs": "tsc -p tsconfig.cjs.json",
21
- "build:es": "tsc -p tsconfig.es.json",
22
- "build:types": "tsc -p tsconfig.types.json",
18
+ "build:cjs": "yarn g:tsc -p tsconfig.cjs.json",
19
+ "build:es": "yarn g:tsc -p tsconfig.es.json",
20
+ "build:types": "yarn g:tsc -p tsconfig.types.json",
23
21
  "build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
24
22
  "stage-release": "rimraf ./.release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz",
25
23
  "clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
26
24
  "lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"",
27
25
  "format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"",
28
26
  "extract:docs": "api-extractor run --local",
29
- "test": "jest"
27
+ "test": "yarn g:jest"
30
28
  },
31
29
  "author": {
32
30
  "name": "AWS SDK for JavaScript Team",