Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ENOENT #117

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/adapter/onebot/11/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function fileToBase64 (file: string, bot: AdapterOneBot11): string {
if (!bot || !file.startsWith('file://') || !bot.adapter.connect) return file
const list = ['127.0.0.1', 'localhost']
const url = new URL(bot.adapter.connect)
return list.includes(url.hostname) ? `base64://${fs.readFileSync(file).toString('base64')}` : file
return list.includes(url.hostname) ? `base64://${fs.readFileSync(file.replace(/^file:\/\//, '')).toString('base64')}` : file
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/utils/common/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class Common {

/** file:// */
const files = file.replace(/^file:\/\//, '')
if (fs.existsSync(files)) return fs.readFileSync(file).toString('base64')
if (fs.existsSync(files)) return fs.readFileSync(files).toString('base64')

/** 无前缀base64:// */
return Buffer.from(file, 'base64').toString('base64')
Expand Down
Loading