Skip to content

Commit 12523f9

Browse files
committed
fix: check for empty string
1 parent d403c4b commit 12523f9

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

cpp/BaseCoderHostObject.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ Value BaseCoderHostObject::get(Runtime& runtime, const PropNameID& propNameId) {
4848
auto algorithm = arguments[1].asObject(runtime).getProperty(runtime, "algorithm").toString(runtime).utf8(runtime);
4949
auto stringToEncode = arguments[0].asString(runtime).utf8(runtime);
5050

51+
if (stringToEncode.length() == 0) {
52+
throw JSError(runtime, "[react-native-jsi-base-coder] The `stringToEncode` cannot be an empty string.");
53+
}
54+
5155
string result;
5256

5357
if (algorithm == "base64Rfc4648") {
@@ -106,7 +110,7 @@ Value BaseCoderHostObject::get(Runtime& runtime, const PropNameID& propNameId) {
106110
auto bytesToDecode = arguments[0].asString(runtime).utf8(runtime);
107111

108112
if (bytesToDecode.length() == 0) {
109-
throw JSError(runtime, "[react-native-jsi-base-coder] The `bytesToDecode` argument is an empty string.");
113+
throw JSError(runtime, "[react-native-jsi-base-coder] The `bytesToDecode` cannot be an empty string.");
110114
}
111115

112116
vector<unsigned char> result;

0 commit comments

Comments
 (0)