Skip to content

Commit ff38e47

Browse files
committed
refactor: use builtin vim.uri_encode for encoding
1 parent 0981217 commit ff38e47

File tree

1 file changed

+1
-11
lines changed

1 file changed

+1
-11
lines changed

lua/tinygit/commands/github.lua

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@ end
1919

2020
--------------------------------------------------------------------------------
2121

22-
---@param unencoded string
23-
---@return string
24-
local function urlEncode(unencoded)
25-
local encoded = unencoded:gsub(
26-
"([^%w%-_.~])",
27-
function(c) return string.format("%%%02X", string.byte(c)) end
28-
)
29-
return encoded
30-
end
31-
3222
---opens current buffer in the browser & copies the link to the clipboard
3323
---normal mode: link to file
3424
---visual mode: link to selected lines
@@ -76,7 +66,7 @@ function M.githubUrl(what)
7666
end
7767
end
7868
local type = what == "blame" and "blame" or "blob"
79-
url = url .. ("/%s/%s/%s%s"):format(type, hash, urlEncode(pathInRepo), location)
69+
url = url .. ("/%s/%s/%s%s"):format(type, hash, vim.uri_encode(pathInRepo), location)
8070

8171
vim.ui.open(url)
8272
vim.fn.setreg("+", url) -- copy to clipboard

0 commit comments

Comments
 (0)