Skip to content

Commit a3d712e

Browse files
committed
add null/undefined check for filter parameters
1 parent a80420f commit a3d712e

3 files changed

Lines changed: 17 additions & 2 deletions

File tree

src/appConfigurationImpl.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -900,6 +900,10 @@ export class AzureAppConfigurationImpl implements AzureAppConfiguration {
900900
}
901901
i++;
902902
}
903+
904+
if (i < pageWatchers.length) {
905+
return true;
906+
}
903907
}
904908
return false;
905909
};

src/featureManagement/featureFlagConverter.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,14 @@ export function convert(featureFlag: AzAppConfigFeatureFlag): FeatureFlag {
9494
return result;
9595
}
9696

97-
function parseParameterValue(value: string): unknown {
97+
function parseParameterValue(value: unknown): unknown {
98+
if (value === undefined || value === null) {
99+
return value;
100+
}
101+
if (typeof value !== "string") {
102+
return value;
103+
}
104+
98105
const trimmedValue = value.trim();
99106
if (trimmedValue.length > 0 && (trimmedValue[0] === "{" || trimmedValue[0] === "[")) {
100107
try {

test/featureFlag.test.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,9 @@ describe("enhanced feature flags", function () {
570570
Audience: JSON.stringify(audience),
571571
JsonArray: " [\"one\",\"two\"] ",
572572
PlainText: "not-json",
573-
Percentage: "50"
573+
Percentage: "50",
574+
NullValue: null,
575+
UndefinedValue: undefined
574576
}
575577
}]
576578
}
@@ -588,6 +590,8 @@ describe("enhanced feature flags", function () {
588590
expect(parameters.JsonArray).deep.equals(["one", "two"]);
589591
expect(parameters.PlainText).equals("not-json");
590592
expect(parameters.Percentage).equals("50");
593+
expect(parameters.NullValue).equals(null);
594+
expect(parameters).has.property("UndefinedValue", undefined);
591595
});
592596

593597
it("should preserve invalid JSON in enhanced feature flag filter parameters as a string", () => {

0 commit comments

Comments
 (0)