Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(6_1_X) [TIMOB-24796] iOS: Hybrid CommonJS and Native modules don't handl… #9132

Merged
merged 4 commits into from
Jun 15, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion iphone/Classes/KrollBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ - (TiModule *)loadCoreModule:(NSString *)path withContext:(KrollContext *)kroll
- (NSString *)loadFile:(NSString *)path
{
NSURL *url_ = [NSURL URLWithString:path relativeToURL:[[self host] baseURL]];
NSData *data = [TiUtils loadAppResource:url_];
NSData *data = [TiUtils loadAppResource:url_]; // try to load encrypted file

if (data == nil) {
data = [NSData dataWithContentsOfURL:url_];
Expand Down
10 changes: 9 additions & 1 deletion iphone/Classes/TiModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,15 @@ -(NSData*)loadModuleAsset:(NSString*)fromPath
{
[self loadAssets];
if ([moduleAssets respondsToSelector:@selector(resolveModuleAsset:)]) {
return [moduleAssets performSelector:@selector(resolveModuleAsset:) withObject:fromPath];
// Look up the file by it's original name. We preserve the filename in our Node-js based module build
NSData* data = [moduleAssets performSelector:@selector(resolveModuleAsset:) withObject:fromPath];
if (data != null) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use nil please

return data;
}
// FIXME Remove once we no longer support modules built by the old python code!
// This tries to load the "mangled" filename generated by our old module build encryption and minification process!
NSString* assetID = [fromPath stringByReplacingOccurrencesOfString:@"." withString:@"_"];
return [moduleAssets performSelector:@selector(resolveModuleAsset:) withObject:assetID];
}
return nil;
}
Expand Down