fix: fix curl GET method can convert space to arguments

This commit is contained in:
JuanZoran
2023-03-12 16:14:03 +08:00
parent 5a36ffad1c
commit 493fad6a3f
6 changed files with 53 additions and 43 deletions

View File

@@ -43,8 +43,8 @@ function M.query(data)
assert(#result == 1)
result = result[1]
data.result.baidu = {
title = result.src,
translation = result.dst,
['title'] = result.src,
[data.from == 'en' and 'translation' or 'definition'] = result.dst,
}
return
end

View File

@@ -13,25 +13,22 @@ vim.api.nvim_create_autocmd('VimLeavePre', {
function M.query(data)
if data.is_word == false or data.from == 'zh' then return end
data.path = data.path or require('Trans').conf.dir .. '/ultimate.db'
data.engine = 'offline'
data.formatter = data.formatter or M.formatter
data.query_field = data.query_field or M.query_field
local path = require('Trans').conf.dir .. '/ultimate.db'
local dict = db:open(data.path)
local dict = db:open(path)
local db_name = data.db_name or 'stardict'
local res = dict:select(db_name, {
where = { word = data.str, },
keys = data.query_field,
keys = M.query_field,
limit = 1,
})[1]
data.result.offline = res and data.formatter(res) or false
data.result.offline = res and M.formatter(res) or false
return data
end
-- this is a awesome plugin
M.query_field = {
'word',
'phonetic',