Skip to content

Commit e06a316

Browse files
committed
🎨 Stop exposing the absolute workspace path to browsers #17410
Signed-off-by: Daniel <845765@qq.com>
1 parent 5eb994e commit e06a316

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

app/src/util/processTitle.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ import {pathPosix} from "./pathName";
55
export const getWorkspaceName = () => {
66
const dir = window.siyuan.config.system.workspaceDir;
77
// 浏览器环境下内核不返回工作空间绝对路径,回退到应用名以避免标题/顶栏出现空段
8+
// 注意:该函数可能在 languages 加载前(如 setBodyHighlight)被调用,故用可选链,
9+
// 此时返回 undefined,由调用方(setBodyHighlight 的 if(!name) return)跳过处理
810
// https://github.com/siyuan-note/siyuan/issues/17410
9-
return dir ? pathPosix().basename(dir.replace(/\\/g, "/")) : window.siyuan.languages.siyuanNote;
11+
return dir ? pathPosix().basename(dir.replace(/\\/g, "/")) : window.siyuan.languages?.siyuanNote;
1012
};
1113

1214
export const setTitle = (title: string, showVersionTitle = false) => {

0 commit comments

Comments
 (0)