Skip to content

Commit

Permalink
temp fix for unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
tyiuhc committed Oct 17, 2024
1 parent 5dc054d commit c96e0da
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/experiment-tag/src/experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {

const appliedInjections: Set<string> = new Set();
const appliedMutations: MutationController[] = [];
let previousUrl: string | undefined = undefined;
let previousUrl: string | undefined;
// Cache to track exposure for the current URL, should be cleared on URL change
let urlExposureCache: { [url: string]: { [key: string]: string | undefined } };

Expand All @@ -40,7 +40,7 @@ export const initializeExperiment = (apiKey: string, initialFlags: string) => {
if (!isLocalStorageAvailable() || !globalScope) {
return;
}
// Clear the cache on initialization
previousUrl = undefined;
urlExposureCache = {};
const experimentStorageName = `EXP_${apiKey.slice(0, 10)}`;
let user: ExperimentUser;
Expand Down Expand Up @@ -352,7 +352,7 @@ const exposureWithDedupe = (key: string, variant: Variant) => {
const currentUrl = urlWithoutParamsAndAnchor(globalScope.location.href);

// Initialize the cache if on a new URL
if (!urlExposureCache[currentUrl]) {
if (!urlExposureCache?.[currentUrl]) {
urlExposureCache = {};
urlExposureCache[currentUrl] = {};
}
Expand Down

0 comments on commit c96e0da

Please sign in to comment.