Skip to content

Commit

Permalink
Merge branch 'master' into TIMOB-26795
Browse files Browse the repository at this point in the history
  • Loading branch information
ssjsamir committed Feb 12, 2019
2 parents 8a63e87 + 9525578 commit ca09897
Show file tree
Hide file tree
Showing 3 changed files with 484 additions and 96 deletions.
18 changes: 9 additions & 9 deletions iphone/TitaniumKit/TitaniumKit/Sources/API/KrollBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -1202,19 +1202,19 @@ - (ResolvedModule *)tryFile:(NSString *)path
if (json) {
type = JSON;
}
return [[ResolvedModule alloc] initWithType:type andPath:path];
return [[[ResolvedModule alloc] initWithType:type andPath:path] autorelease];
}

// 2. If X.js is a file, load X.js as JavaScript text. STOP
NSString *asJS = [path stringByAppendingString:@".js"];
if ([self fileExists:asJS]) {
return [[ResolvedModule alloc] initWithType:JS andPath:asJS];
return [[[ResolvedModule alloc] initWithType:JS andPath:asJS] autorelease];
}

// 3. If X.json is a file, parse X.json to a JavaScript Object. STOP
NSString *asJSON = [path stringByAppendingString:@".json"];
if ([self fileExists:asJSON]) {
return [[ResolvedModule alloc] initWithType:JSON andPath:asJSON];
return [[[ResolvedModule alloc] initWithType:JSON andPath:asJSON] autorelease];
}

return nil;
Expand All @@ -1230,12 +1230,12 @@ - (ResolvedModule *)tryDirectory:(NSString *)path

NSString *indexJS = [path stringByAppendingPathComponent:@"index.js"];
if ([self fileExists:indexJS]) {
return [[ResolvedModule alloc] initWithType:JS andPath:indexJS];
return [[[ResolvedModule alloc] initWithType:JS andPath:indexJS] autorelease];
}

NSString *indexJSON = [path stringByAppendingPathComponent:@"index.json"];
if ([self fileExists:indexJSON]) {
return [[ResolvedModule alloc] initWithType:JSON andPath:indexJSON];
return [[[ResolvedModule alloc] initWithType:JSON andPath:indexJSON] autorelease];
}
return nil;
}
Expand Down Expand Up @@ -1268,14 +1268,14 @@ - (ResolvedModule *)tryNativeModule:(NSString *)path
// Are they just trying to load the top-level module? If so, return that as our path
NSRange separatorLocation = [path rangeOfString:@"/"];
if (separatorLocation.location == NSNotFound) {
return [[ResolvedModule alloc] initWithType:Native andPath:moduleID];
return [[[ResolvedModule alloc] initWithType:Native andPath:moduleID] autorelease];
}

// check rest of path
NSString *assetPath = [path substringFromIndex:separatorLocation.location + 1];
// Treat require('module.id/module.id') == require('module.id')
if ([assetPath isEqualToString:moduleID]) {
return [[ResolvedModule alloc] initWithType:Native andPath:moduleID];
return [[[ResolvedModule alloc] initWithType:Native andPath:moduleID] autorelease];
}

// we need to load the actual module to determine beyond this...
Expand All @@ -1299,7 +1299,7 @@ - (ResolvedModule *)tryNativeModule:(NSString *)path
return nil;
}
// asset inside module
return [[ResolvedModule alloc] initWithType:NativeJS andPath:filepath];
return [[[ResolvedModule alloc] initWithType:NativeJS andPath:filepath] autorelease];
}

- (NSString *)pathByStandarizingPath:(NSString *)relativePath
Expand Down Expand Up @@ -1338,7 +1338,7 @@ - (ResolvedModule *)resolveRequire:(NSString *)path withWorkingPath:(NSString *)
// For CommonJS we need to look for module.id/module.id.js first...
NSString *filename = [[path stringByAppendingPathComponent:path] stringByAppendingPathExtension:@"js"];
if ([self fileExists:filename]) {
return [[ResolvedModule alloc] initWithType:JS andPath:filename];
return [[[ResolvedModule alloc] initWithType:JS andPath:filename] autorelease];
}

// Then try module.id as directory
Expand Down

0 comments on commit ca09897

Please sign in to comment.