mirror of
https://github.com/pesde-pkg/tooling.git
synced 2024-12-12 07:10:36 +00:00
fix: correctly parse base64 with whitespace
This commit is contained in:
parent
3e22a38dca
commit
ad36473326
10 changed files with 9 additions and 18 deletions
|
@ -167,7 +167,7 @@ for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
|
|||
type = "Custom",
|
||||
payload = {
|
||||
method = "GET",
|
||||
url = `https://api.github.com/repos/{repoName}/contents/README.md`,
|
||||
url = `https://api.github.com/repos/{repoName}/readme`,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -181,20 +181,10 @@ for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
|
|||
-- NOTE: Github uses a special format for encoding the contents, where it
|
||||
-- separates the entire file into multiple lines, and encodes each line in
|
||||
-- base64
|
||||
local lines = string.split(resp.content, "\n")
|
||||
local decoded = buffer.create(resp.size)
|
||||
local cum = 0
|
||||
for _, line in lines do
|
||||
if line == "" then
|
||||
-- Skip empty lines
|
||||
continue
|
||||
end
|
||||
|
||||
local src = base64.decode(buffer.fromstring(line))
|
||||
buffer.copy(decoded, math.clamp(cum - 1, 0, math.huge), src)
|
||||
cum += buffer.len(src)
|
||||
end
|
||||
|
||||
-- This should be done by the base64 library, but oh well
|
||||
local content = string.gsub(resp.content, "%s+", "")
|
||||
local decoded = base64.decode(buffer.fromstring(content))
|
||||
return Result.Ok(decoded)
|
||||
end
|
||||
|
||||
|
@ -210,6 +200,8 @@ for _, binSrc in pathfs.readDir(BINS_SRC_DIR) do
|
|||
|
||||
-- Write the updated README to the tool's directory
|
||||
local readmeContents = readmeRes:unwrap()
|
||||
-- There used to be some issues with encoding if not deleted and recreated
|
||||
pathfs.removeFile(readmePath)
|
||||
pathfs.writeFile(readmePath, readmeContents)
|
||||
|
||||
print(
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,7 @@
|
|||
<div align="center">
|
||||
<h1>
|
||||
StyLua<br>
|
||||
<ahref="https://crates.io/crates/stylua"><img src="https://img.shields.io/crates/v/stylua.svg"></a>
|
||||
<a href="https://crates.io/crates/stylua"><img src="https://img.shields.io/crates/v/stylua.svg"></a>
|
||||
<a href="https://github.com/JohnnyMorganz/StyLua/actions/workflows/ci.yml"><img src="https://github.com/JohnnyMorganz/StyLua/actions/workflows/ci.yml/badge.svg"></a>
|
||||
<a href="https://codecov.io/gh/JohnnyMorganz/StyLua"><img src="https://codecov.io/gh/JohnnyMorganz/StyLua/branch/main/graph/badge.svg"/></a>
|
||||
</h1>
|
||||
|
@ -301,4 +301,3 @@ space_after_function_names = "Never"
|
|||
[sort_requires]
|
||||
enabled = false
|
||||
```
|
||||
|