mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-24 02:30:03 +00:00
!6291 SetModuleName should consider harName(check @)
Merge pull request !6291 from yaochaonan/ohcard
This commit is contained in:
commit
1f0a2c6dc2
@ -777,7 +777,6 @@ std::pair<std::string, std::string> EcmaVM::GetCurrentModuleInfo(bool needRecord
|
||||
return std::make_pair(recordName.c_str(), fileName.c_str());
|
||||
}
|
||||
CString moduleName = ModulePathHelper::GetModuleName(recordName);
|
||||
PathHelper::DeleteNamespace(moduleName);
|
||||
if (moduleName.empty()) {
|
||||
LOG_FULL(ERROR) << " GetCurrentModuleName Fail, recordName is " << recordName;
|
||||
}
|
||||
|
@ -192,7 +192,9 @@ public:
|
||||
pos1++;
|
||||
size_t pos2 = recordName.find(PathHelper::SLASH_TAG, pos1);
|
||||
if (pos2 != CString::npos) {
|
||||
return recordName.substr(pos1, pos2 - pos1);
|
||||
CString moduleName = recordName.substr(pos1, pos2 - pos1);
|
||||
PathHelper::DeleteNamespace(moduleName);
|
||||
return moduleName;
|
||||
}
|
||||
}
|
||||
return CString();
|
||||
|
@ -2566,10 +2566,19 @@ void JSNApi::SetModuleInfo(EcmaVM *vm, const std::string &assetPath, const std::
|
||||
{
|
||||
SetAssetPath(vm, assetPath);
|
||||
size_t pos = entryPoint.find_first_of("/");
|
||||
SetBundleName(vm, entryPoint.substr(0, pos));
|
||||
std::string subStr = entryPoint.substr(pos + 1); // 1: remove /
|
||||
pos = subStr.find_first_of("/");
|
||||
SetModuleName(vm, subStr.substr(0, pos));
|
||||
if (pos != std::string::npos) {
|
||||
SetBundleName(vm, entryPoint.substr(0, pos));
|
||||
ecmascript::CString moduleName = ModulePathHelper::GetModuleName(entryPoint.c_str());
|
||||
if (!moduleName.empty()) {
|
||||
SetModuleName(vm, moduleName.c_str());
|
||||
return;
|
||||
}
|
||||
}
|
||||
std::string errmsg = "SetModuleInfo: entryPoint:" + entryPoint + "is invalid.";
|
||||
LOG_ECMA(ERROR) << errmsg;
|
||||
Local<StringRef> message = StringRef::NewFromUtf8(vm, errmsg.c_str());
|
||||
Local<JSValueRef> error = Exception::Error(vm, message);
|
||||
JSNApi::ThrowException(vm, error);
|
||||
}
|
||||
|
||||
// note: The function SetAssetPath is a generic interface for previewing and physical machines.
|
||||
|
Loading…
Reference in New Issue
Block a user