Skip to content

Commit c27879f

Browse files
authored
Allow dot, solidus, percent and colon characters in profile names (#1067)
1 parent 7de91ee commit c27879f

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

.changeset/shiny-beans-wink.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@smithy/shared-ini-file-loader": patch
3+
---
4+
5+
Allow dot, solidus, percent and colon characters in profile names

packages/shared-ini-file-loader/src/parseIni.spec.ts

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,21 @@ describe(parseIni.name, () => {
6161
// Some characters are not allowed in profile name, but we parse them as customers use them.
6262
// `@` https://github.com/awslabs/smithy-typescript/issues/1026
6363
// `+` https://github.com/aws/aws-sdk-js-v3/issues/5373
64-
it.each(["-", "_", "@", "+"])("returns data for character '%s' in profile name", (specialChar: string) => {
65-
const mockProfileName = ["profile", "stage"].join(specialChar);
66-
const mockSectionFullName = ["profile", mockProfileName].join(" ");
67-
const mockInput = getMockProfileContent(mockSectionFullName, mockProfileData);
68-
expect(parseIni(mockInput)).toStrictEqual({
69-
[["profile", mockProfileName].join(CONFIG_PREFIX_SEPARATOR)]: mockProfileData,
70-
});
71-
});
64+
// `.` https://github.com/aws/aws-sdk-js-v3/issues/5449
65+
// `/` https://github.com/awslabs/smithy-typescript/issues/1053
66+
// `%` https://github.com/aws/aws-sdk-java-v2/pull/1538
67+
// `:` https://github.com/aws/aws-sdk-java-v2/pull/1898
68+
it.each(["-", "_", "@", "+", ".", "/", "%", ":"])(
69+
"returns data for character '%s' in profile name",
70+
(specialChar: string) => {
71+
const mockProfileName = ["profile", "stage"].join(specialChar);
72+
const mockSectionFullName = ["profile", mockProfileName].join(" ");
73+
const mockInput = getMockProfileContent(mockSectionFullName, mockProfileData);
74+
expect(parseIni(mockInput)).toStrictEqual({
75+
[["profile", mockProfileName].join(CONFIG_PREFIX_SEPARATOR)]: mockProfileData,
76+
});
77+
}
78+
);
7279

7380
it("returns data for two profiles", () => {
7481
const mockProfile1 = getMockProfileContent(mockProfileName, mockProfileData);

packages/shared-ini-file-loader/src/parseIni.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { IniSectionType, ParsedIniData } from "@smithy/types";
22

33
import { CONFIG_PREFIX_SEPARATOR } from "./loadSharedConfigFiles";
44

5-
const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+]+)\2$/;
5+
const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/;
66
const profileNameBlockList = ["__proto__", "profile __proto__"];
77

88
export const parseIni = (iniData: string): ParsedIniData => {

0 commit comments

Comments
 (0)