|
100 | 100 | }
|
101 | 101 |
|
102 | 102 | NSString* normalizePath(NSString* path) {
|
103 |
| - NSArray* pathComponents = [path componentsSeparatedByString:@"/"]; |
| 103 | + NSArray<NSString*>* pathComponents = [path componentsSeparatedByString:@"/"]; |
104 | 104 | NSMutableArray* stack = [[NSMutableArray alloc] initWithCapacity:pathComponents.count];
|
105 | 105 | for (NSString* pathComponent in pathComponents) {
|
106 | 106 | if ([pathComponent isEqualToString:@".."]) {
|
|
113 | 113 | if ([path hasPrefix:@"/"]) {
|
114 | 114 | result = [@"/" stringByAppendingString:result];
|
115 | 115 | }
|
| 116 | + [stack release]; |
116 | 117 | return result;
|
117 | 118 | }
|
118 | 119 |
|
|
247 | 248 | return deferred->reject(execState, createTypeError(execState, WTF::String::format("Unexpected module source type '%s'.", NSStringFromClass([source class]).UTF8String)));
|
248 | 249 | }
|
249 | 250 |
|
250 |
| - return deferred->resolve(execState, jsString(execState, contents)); |
| 251 | + JSC::JSString* contentsJs = jsString(execState, contents); |
| 252 | + [contents release]; |
| 253 | + return deferred->resolve(execState, contentsJs); |
251 | 254 | }
|
252 | 255 |
|
253 | 256 | static JSModuleRecord* parseModule(ExecState* execState, const SourceCode& sourceCode, const Identifier& moduleKey, ParserError& parserError) {
|
|
393 | 396 | args.append(moduleKey);
|
394 | 397 | JSValue entry = JSC::call(execState, function, callType, callData, moduleLoader, args);
|
395 | 398 | record = jsCast<JSModuleRecord*>(entry.get(execState, Identifier::fromString(execState, "module")));
|
396 |
| - |
| 399 | + |
397 | 400 | if (frame.check()) {
|
398 | 401 | NSString* moduleName = (NSString*)moduleKey.toWTFString(execState).createCFString().get();
|
399 | 402 | NSString* appPath = [TNSRuntime current].applicationPath;
|
400 |
| - if ([moduleName hasPrefix: appPath]) { |
| 403 | + if ([moduleName hasPrefix:appPath]) { |
401 | 404 | moduleName = [moduleName substringFromIndex:appPath.length];
|
402 | 405 | }
|
403 |
| - frame.log([@"require: " stringByAppendingString: moduleName].UTF8String); |
| 406 | + frame.log([@"require: " stringByAppendingString:moduleName].UTF8String); |
404 | 407 | }
|
405 | 408 |
|
406 | 409 | return JSValue::encode(jsUndefined());
|
|
0 commit comments