Skip to content

Commit 720641f

Browse files
committed
update ci and add uri encode
1 parent 50ebeed commit 720641f

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.github/workflows/ci.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,12 @@ jobs:
9595
!TestData/feature-flags3.json
9696
app-configuration-endpoint: ${{ vars.APP_CONFIGURATION_ENDPOINT }}
9797
strict: true
98+
99+
- name: Test Local Action with label
100+
id: test-action-label
101+
uses: ./
102+
with:
103+
path: TestData/*.json
104+
app-configuration-endpoint: ${{ vars.APP_CONFIGURATION_ENDPOINT }}
105+
strict: true
106+
label: test label

__tests__/feature-flag-client.test.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,10 +87,11 @@ describe('Feature Flag Client', () => {
8787
)
8888
})
8989

90-
it('can create or update feature flag with non-empty label', async () => {
90+
it('can create or update feature flag with label', async () => {
9191
const appConfigEndpoint = 'https://example.com'
9292
const featureFlagId = 'featureFlagId1'
93-
const label = 'test-label'
93+
// Use a label with special characters to test URL encoding
94+
const label = 'test label/with special&chars'
9495
const value = getDummyFeatureFlagItem(featureFlagId)
9596

9697
const getMock = jest.spyOn(axios, 'put').mockResolvedValue({
@@ -104,7 +105,7 @@ describe('Feature Flag Client', () => {
104105
label
105106
)
106107
expect(getMock).toBeCalledWith(
107-
`${appConfigEndpoint}/kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01&label=test-label`,
108+
`${appConfigEndpoint}/kv/.appconfig.featureflag%2FfeatureFlagId1?api-version=2023-11-01&label=test%20label%2Fwith%20special%26chars`,
108109
{
109110
content_type:
110111
'application/vnd.microsoft.appconfig.ff+json;charset=utf-8',

src/feature-flag-client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const createOrUpdateFeatureFlag = async (
4141
value: JSON.stringify(value)
4242
}
4343
const response = await axios.put(
44-
`${appConfigEndpoint}/kv/${getAppConfigKey(featureFlagId)}?api-version=${apiVersion}&label=${label}`,
44+
`${appConfigEndpoint}/kv/${getAppConfigKey(encodeURIComponent(featureFlagId))}?api-version=${apiVersion}&label=${encodeURIComponent(label)}`,
4545
payload,
4646
{ headers: await getHeaders(appConfigEndpoint) }
4747
)
@@ -59,7 +59,7 @@ export const deleteFeatureFlag = async (
5959
label: string
6060
): Promise<void> => {
6161
const response = await axios.delete(
62-
`${appConfigEndpoint}/kv/${getAppConfigKey(featureFlagId)}?api-version=${apiVersion}&label=${label}`,
62+
`${appConfigEndpoint}/kv/${getAppConfigKey(featureFlagId)}?api-version=${apiVersion}&label=${encodeURIComponent(label)}`,
6363
{ headers: await getHeaders(appConfigEndpoint) }
6464
)
6565

0 commit comments

Comments
 (0)