Skip to content

Commit 1256724

Browse files
author
Mariusz Pasinski
committed
fix: explicitly cast pathPrefix to std::string for lookup
1 parent 6323948 commit 1256724

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/react-native-node-api-modules/cpp/CxxNodeApiHostModule.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,12 @@ CxxNodeApiHostModule::requireNodeAddon(jsi::Runtime &rt,
167167
const auto [pathPrefix, strippedPath] = rpartition(requiredPath, ':');
168168
if (!pathPrefix.empty()) {
169169
// URL protocol or prefix detected, dispatch via custom resolver
170-
if (auto handler = prefixResolvers_.find(pathPrefix); prefixResolvers_.end() != handler) {
170+
std::string pathPrefixCopy(pathPrefix); // HACK: Need explicit cast to `std::string`
171+
if (auto handler = prefixResolvers_.find(pathPrefixCopy); prefixResolvers_.end() != handler) {
171172
// HACK: Smuggle the `pathPrefix` as new `requiredPackageName`
172173
return (handler->second)(rt, strippedPath, pathPrefix, requiredFrom);
173174
} else {
174-
throw jsi::JSError(rt, "Unsupported protocol or prefix \"" + pathPrefix + "\". Have you registered it?");
175+
throw jsi::JSError(rt, "Unsupported protocol or prefix \"" + pathPrefixCopy + "\". Have you registered it?");
175176
}
176177
}
177178

0 commit comments

Comments
 (0)