From 62431038bb5e204d53bc2943c44ff282442e82f7 Mon Sep 17 00:00:00 2001 From: "Juan Picado @jotadeveloper" Date: Sun, 28 Jul 2019 17:51:46 +0200 Subject: [PATCH] chore: improve types and checks --- src/components/ActionBar/ActionBar.tsx | 4 ++-- src/utils/api.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/ActionBar/ActionBar.tsx b/src/components/ActionBar/ActionBar.tsx index 8d178e8..51b05f8 100644 --- a/src/components/ActionBar/ActionBar.tsx +++ b/src/components/ActionBar/ActionBar.tsx @@ -17,7 +17,7 @@ export interface Action { handler?: Function; } -async function downloadHandler(link: string): Promise { +export async function downloadHandler(link: string): Promise { const fileStream: Blob = await api.request(link, 'GET', { headers: { ['accept']: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3', @@ -73,7 +73,7 @@ class ActionBar extends Component { tarball, }; - const renderList = Object.keys(actionsMap).reduce((component, value, key) => { + const renderList = Object.keys(actionsMap).reduce((component: React.ReactElement[], value, key) => { const link = actionsMap[value]; if (link && isURL(link)) { const actionItem: Action = ACTIONS[value]; diff --git a/src/utils/api.ts b/src/utils/api.ts index 76af354..c869881 100644 --- a/src/utils/api.ts +++ b/src/utils/api.ts @@ -21,7 +21,7 @@ function handleResponseType(response: Response): Promise<[boolean, Blob | string } // unfortunatelly on download files there is no header available - if (response.url.match(/tgz/).length > 0) { + if (response.url && response.url.match(/.tgz/) !== null) { return Promise.all([response.ok, response.blob()]); } }