Skip to content

Fix Windows import filenames / 修复 Windows 导入文件名提取 - #21

Merged
VallierDev merged 1 commit into
VallierDev:mainfrom
eerraa:fix/windows-import-filename
Sep 19, 2026
Merged

VallierDev merged 1 commit into
VallierDev:mainfrom
eerraa:fix/windows-import-filename

Conversation

@eerraa

@eerraa eerraa commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

English · 简体中文

English

Pass a filename—not an entire Windows path—in the account import payload's filename field. One production line changes.

Problem and minimal fix

The file picker can return a path such as C:\Users\name\Downloads\accounts.json. Splitting only on / leaves that whole string in filename instead of accounts.json; UNC paths have the same issue.

- const filename = p.split('/').pop() || p;
+ const filename = p.split(/[\\/]/).pop() || p;

The file is still read from the original full path. Only the filename metadata sent to the backend changes. File contents, format parsing, account deduplication, and credentials are untouched. This does not claim that every Windows import fails; it corrects the basename extraction itself.

Verification

Local Windows validation at head 689c39d passed:

npm run build
node --test scripts/import-filename.test.mjs

The 2 tests evaluate the actual source expression with Windows drive paths, UNC paths, Unicode/spaces, POSIX paths, mixed separators, and plain filenames. They test extraction, not native file-picker interaction.

Review surface: 2 files, +24/−1 lines including tests; one commit directly on upstream main (f64a44a). No dependency on another PR. #17 edits a different part of the same modal for OAuth links; this filename fix can be accepted independently.


简体中文

让账号导入请求的 filename 字段收到文件名,而不是整条 Windows 路径。实际代码只改一行。

问题与最小修正

文件选择器可能返回 C:\Users\name\Downloads\accounts.json。现有代码只按 / 分割,因此 filename 仍是完整路径,而非 accounts.json;UNC 路径也存在同样的问题。

- const filename = p.split('/').pop() || p;
+ const filename = p.split(/[\\/]/).pop() || p;

读取文件时仍使用原始完整路径,只修正传给后端的文件名字段。**不改文件内容、格式解析、账号去重或凭据。**这里并不是说所有 Windows 导入都会失败,而是修正文件名提取这一处明确的不一致。

验证依据

在 Windows 上针对当前提交 689c39d 完成本地验证:

npm run build
node --test scripts/import-filename.test.mjs

2 个测试直接执行源码中的提取表达式,覆盖 Windows 盘符路径、UNC 路径、Unicode/空格、POSIX 路径、混合分隔符和单独文件名。测试针对路径提取,不将其表述为原生文件选择器交互测试。

**审阅范围:**含测试共 2 个文件、+24/−1 行,直接基于 upstream main(f64a44a)的单个提交,不依赖其他 PR。#17 修改同一弹窗中的 OAuth 链接区域,与本行无关,本修正可单独接受。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants