diff --git a/.changeset/shiny-beans-wink.md b/.changeset/shiny-beans-wink.md new file mode 100644 index 00000000000..f55f1eb6684 --- /dev/null +++ b/.changeset/shiny-beans-wink.md @@ -0,0 +1,5 @@ +--- +"@smithy/shared-ini-file-loader": patch +--- + +Allow dot, solidus, percent and colon characters in profile names diff --git a/packages/shared-ini-file-loader/src/parseIni.spec.ts b/packages/shared-ini-file-loader/src/parseIni.spec.ts index cf075b4659c..efa7ecc1ead 100644 --- a/packages/shared-ini-file-loader/src/parseIni.spec.ts +++ b/packages/shared-ini-file-loader/src/parseIni.spec.ts @@ -61,14 +61,21 @@ describe(parseIni.name, () => { // Some characters are not allowed in profile name, but we parse them as customers use them. // `@` https://github.com/awslabs/smithy-typescript/issues/1026 // `+` https://github.com/aws/aws-sdk-js-v3/issues/5373 - it.each(["-", "_", "@", "+"])("returns data for character '%s' in profile name", (specialChar: string) => { - const mockProfileName = ["profile", "stage"].join(specialChar); - const mockSectionFullName = ["profile", mockProfileName].join(" "); - const mockInput = getMockProfileContent(mockSectionFullName, mockProfileData); - expect(parseIni(mockInput)).toStrictEqual({ - [["profile", mockProfileName].join(CONFIG_PREFIX_SEPARATOR)]: mockProfileData, - }); - }); + // `.` https://github.com/aws/aws-sdk-js-v3/issues/5449 + // `/` https://github.com/awslabs/smithy-typescript/issues/1053 + // `%` https://github.com/aws/aws-sdk-java-v2/pull/1538 + // `:` https://github.com/aws/aws-sdk-java-v2/pull/1898 + it.each(["-", "_", "@", "+", ".", "/", "%", ":"])( + "returns data for character '%s' in profile name", + (specialChar: string) => { + const mockProfileName = ["profile", "stage"].join(specialChar); + const mockSectionFullName = ["profile", mockProfileName].join(" "); + const mockInput = getMockProfileContent(mockSectionFullName, mockProfileData); + expect(parseIni(mockInput)).toStrictEqual({ + [["profile", mockProfileName].join(CONFIG_PREFIX_SEPARATOR)]: mockProfileData, + }); + } + ); it("returns data for two profiles", () => { const mockProfile1 = getMockProfileContent(mockProfileName, mockProfileData); diff --git a/packages/shared-ini-file-loader/src/parseIni.ts b/packages/shared-ini-file-loader/src/parseIni.ts index afd28d01db1..b8c932c108a 100644 --- a/packages/shared-ini-file-loader/src/parseIni.ts +++ b/packages/shared-ini-file-loader/src/parseIni.ts @@ -2,7 +2,7 @@ import { IniSectionType, ParsedIniData } from "@smithy/types"; import { CONFIG_PREFIX_SEPARATOR } from "./loadSharedConfigFiles"; -const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+]+)\2$/; +const prefixKeyRegex = /^([\w-]+)\s(["'])?([\w-@\+\.%:/]+)\2$/; const profileNameBlockList = ["__proto__", "profile __proto__"]; export const parseIni = (iniData: string): ParsedIniData => {