Skip to content

Commit 8e0c738

Browse files
committed
fix: 🐛 correctly access PUBLIC_ENV_KEY on window
1 parent b46128b commit 8e0c738

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/script/env-script.spec.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('EnvProvider', () => {
2727
const { getByTestId } = render(<EnvScript env={env} />);
2828

2929
expect(getByTestId('env-script').textContent).toBe(
30-
`window[__ENV] = ${JSON.stringify(env)}`,
30+
`window['__ENV'] = ${JSON.stringify(env)}`,
3131
);
3232
});
3333

src/script/env-script.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const EnvScript: FC<EnvScriptProps> = ({ env, nonce }) => {
4040
data-testid="env-script"
4141
nonce={nonceString}
4242
dangerouslySetInnerHTML={{
43-
__html: `window[${PUBLIC_ENV_KEY}] = ${JSON.stringify(env)}`,
43+
__html: `window['${PUBLIC_ENV_KEY}'] = ${JSON.stringify(env)}`,
4444
}}
4545
/>
4646
);

src/script/public-env-script.spec.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe('PublicEnvProvider', () => {
2929
const { getByTestId } = render(<PublicEnvScript />);
3030

3131
expect(getByTestId('env-script').textContent).toBe(
32-
`window[__ENV] = {"NEXT_PUBLIC_FOO":"foo-value"}`,
32+
`window['__ENV'] = {"NEXT_PUBLIC_FOO":"foo-value"}`,
3333
);
3434
});
3535

@@ -40,7 +40,7 @@ describe('PublicEnvProvider', () => {
4040

4141
const { getByTestId } = render(<PublicEnvScript />);
4242

43-
expect(getByTestId('env-script').textContent).toBe(`window[__ENV] = {}`);
43+
expect(getByTestId('env-script').textContent).toBe(`window['__ENV'] = {}`);
4444
});
4545

4646
it('should only set public env in the script', () => {
@@ -52,7 +52,7 @@ describe('PublicEnvProvider', () => {
5252
const { getByTestId } = render(<PublicEnvScript />);
5353

5454
expect(getByTestId('env-script').textContent).toBe(
55-
`window[__ENV] = {"NEXT_PUBLIC_FOO":"foo-value"}`,
55+
`window['__ENV'] = {"NEXT_PUBLIC_FOO":"foo-value"}`,
5656
);
5757
});
5858

0 commit comments

Comments
 (0)