Skip to content
This repository was archived by the owner on Nov 10, 2020. It is now read-only.

Commit 3159733

Browse files
committed
Fix settings sanitization immutability issue
Since Object assignment in Javascript is by reference and not by value, the `sanitiziedSettings` initialization in both sanitiziation functions would actually modify the `defaultSettings` which should be immutable. This commit fixes this issue by initializing `sanitizedSettings` with the object spread operator so to not create a reference but create a new object instead.
1 parent aba12ff commit 3159733

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@matt-block/react-native-in-app-browser",
3-
"version": "1.1.0-rc.1",
3+
"version": "1.1.0",
44
"description": "React Native in-app browser",
55
"keywords": [
66
"in-app",
@@ -75,4 +75,4 @@
7575
"git add"
7676
]
7777
}
78-
}
78+
}

src/settings.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ export function sanitize(os: PlatformOSType, settings?: Settings) {
182182
}
183183

184184
function sanitizeAndroid(settings?: SettingsAndroid): SettingsAndroid {
185-
const sanitizedSettings = defaultSettings.android!;
185+
const sanitizedSettings = { ...defaultSettings.android! };
186186

187187
if (!settings) {
188188
return sanitizedSettings;
@@ -222,7 +222,7 @@ function sanitizeAndroid(settings?: SettingsAndroid): SettingsAndroid {
222222
}
223223

224224
function sanitizeIOS(settings?: SettingsIOS): SettingsIOS {
225-
const sanitizedSettings = defaultSettings.ios!;
225+
const sanitizedSettings = { ...defaultSettings.ios! };
226226

227227
if (!settings) {
228228
return sanitizedSettings;

0 commit comments

Comments
 (0)