Skip to content

Commit 168c8e4

Browse files
committed
fix(Bridge): Native bridge is expected to normalize module names
A long time ago, before we had the `windows` platform option working, we were matching iOS names (e.g., RK*, RCT*) for modules. These names haven't changed, but the requirements for normalizing these prefixes away has.
1 parent 7a99f4f commit 168c8e4

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

ReactWindows/ReactNative/Bridge/NativeModuleRegistry.cs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,13 +291,30 @@ public NativeModuleRegistry Build()
291291

292292
foreach (var module in _modules.Values)
293293
{
294-
var moduleDef = new ModuleDefinition(module.Name, module);
294+
var name = NormalizeModuleName(module.Name);
295+
var moduleDef = new ModuleDefinition(name, module);
295296
moduleTable.Add(moduleDef);
296297
moduleInstances.Add(module.GetType(), module);
297298
}
298299

299300
return new NativeModuleRegistry(moduleTable, moduleInstances);
300301
}
302+
303+
private static string NormalizeModuleName(string name)
304+
{
305+
if (name.StartsWith("RCT"))
306+
{
307+
return name.Substring(3);
308+
}
309+
else if (name.StartsWith("RK"))
310+
{
311+
return name.Substring(2);
312+
}
313+
else
314+
{
315+
return name;
316+
}
317+
}
301318
}
302319
}
303320
}

0 commit comments

Comments
 (0)