mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-07-21 07:05:22 -04:00
Reconstruct code for readability.
Signed-off-by: lichenshuai <lichenshuai@huawei.com>
This commit is contained in:
@@ -137,6 +137,29 @@ JSHandle<JSTaggedValue> ModuleManager::GetModule(const JSThread *thread,
|
||||
return thread->GlobalConstants()->GetHandledUndefined();
|
||||
}
|
||||
|
||||
CString ModuleManager::GenerateModuleFullPath(const std::string ¤tPathFile, const CString &relativeFile)
|
||||
{
|
||||
if (relativeFile.find("./") != 0 && relativeFile.find("../") != 0) { // not start with "./" or "../"
|
||||
return relativeFile; // not relative
|
||||
}
|
||||
|
||||
auto slashPos = currentPathFile.find_last_of('/');
|
||||
if (slashPos == std::string::npos) {
|
||||
return relativeFile; // no need to process
|
||||
}
|
||||
|
||||
auto dotPos = relativeFile.find_last_of(".");
|
||||
if (dotPos == std::string::npos) {
|
||||
dotPos = 0;
|
||||
}
|
||||
|
||||
CString fullPath;
|
||||
fullPath.append(currentPathFile.substr(0, slashPos + 1)); // 1: with "/"
|
||||
fullPath.append(relativeFile.substr(0, dotPos));
|
||||
fullPath.append(".abc"); // ".js" -> ".abc"
|
||||
return fullPath;
|
||||
}
|
||||
|
||||
const CString &ModuleManager::GetCurrentExportModuleName()
|
||||
{
|
||||
return moduleStack_.GetTop();
|
||||
|
||||
Reference in New Issue
Block a user