Skip to content

Commit 5eed622

Browse files
committed
fix: incorrect return file logic
1 parent 1243c5f commit 5eed622

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/getPlatform.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export function checkPlatform(
1313
fileName: string,
1414
): string | undefined {
1515
const extension = extname(fileName)
16-
1716
// OSX we should have our .app tar.gz
1817
if (
1918
(fileName.includes('.app') ||
@@ -28,7 +27,7 @@ export function checkPlatform(
2827
// Windows 64 bits
2928
if (
3029
(fileName.includes('x64') || fileName.includes('win64')) &&
31-
(extension === 'zip' || extension === 'msi') &&
30+
extension === 'zip' &&
3231
platform === AVAILABLE_PLATFORMS.Win64
3332
) {
3433
return 'win64'
@@ -63,8 +62,6 @@ export async function findAssetSignature(
6362
): Promise<string | null> {
6463
// check in our assets if we have a file: `fileName.sig`
6564
// by example fileName can be: App-1.0.0.zip
66-
console.log('matching: ', fileName)
67-
console.log(assets.map((a) => a.name))
6865
const matches = [
6966
`${fileName.toLowerCase()}.gz.sig`,
7067
`${fileName.toLowerCase()}.zip.sig`,

src/handler.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,28 @@ const GITHUB_REPO = 'brancato'
1212
export async function handleRequest(request: Request): Promise<Response> {
1313
const path = new URL(request.url).pathname
1414
const [platform, version] = path.slice(1).split('/')
15-
if (!platform || !validatePlatform(platform) || !version) {
16-
return new Response('Not found', { status: 404 })
17-
}
15+
1816
const reqUrl = new URL(
1917
`https://api.github.com/repos/${GITHUB_ACCOUNT}/${GITHUB_REPO}/releases/latest`,
2018
)
2119
const headers = new Headers({
2220
Accept: 'application/vnd.github.preview',
2321
'User-Agent': request.headers.get('User-Agent') as string,
2422
})
25-
const release = (await fetch(reqUrl.toString(), {
23+
const releaseResponse = await fetch(reqUrl.toString(), {
2624
method: 'GET',
2725
headers,
28-
}).then((resp) => resp.json())) as {
26+
})
27+
28+
const release = (await releaseResponse.clone().json()) as {
2929
tag_name: string
3030
assets: any
3131
body: any
3232
published_at: string
3333
}
34-
34+
if (!platform || !validatePlatform(platform) || !version) {
35+
return releaseResponse
36+
}
3537
const remoteVersion = sanitizeVersion(release.tag_name.toLowerCase())
3638

3739
if (!remoteVersion || !semverValid(remoteVersion)) {

0 commit comments

Comments
 (0)