diff --git a/src/font/cli.go b/src/font/cli.go index 533af0fd..c62fcf63 100644 --- a/src/font/cli.go +++ b/src/font/cli.go @@ -139,11 +139,11 @@ func (m *main) Init() tea.Cmd { return tea.Quit } - isZipFile := func() bool { - return strings.HasSuffix(m.font, ".zip") + isLocalZipFile := func() bool { + return !strings.HasPrefix(m.font, "https") && strings.HasSuffix(m.font, ".zip") } - if len(m.font) != 0 && !isZipFile() { + if len(m.font) != 0 && !isLocalZipFile() { m.state = downloadFont if !strings.HasPrefix(m.font, "https") { m.font = fmt.Sprintf("https://github.com/ryanoasis/nerd-fonts/releases/latest/download/%s.zip", m.font) @@ -156,7 +156,7 @@ func (m *main) Init() tea.Cmd { } defer func() { - if isZipFile() { + if isLocalZipFile() { go installLocalFontZIP(m.font) return } @@ -167,7 +167,7 @@ func (m *main) Init() tea.Cmd { s.Style = lipgloss.NewStyle().Foreground(lipgloss.Color("170")) m.spinner = s m.state = getFonts - if isZipFile() { + if isLocalZipFile() { m.state = unzipFont } return m.spinner.Tick diff --git a/src/font/download.go b/src/font/download.go index 08b9a4de..c2eb0c75 100644 --- a/src/font/download.go +++ b/src/font/download.go @@ -58,7 +58,7 @@ func getRemoteFile(location string) (data []byte, err error) { defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - return + return data, fmt.Errorf("Failed to download zip file: %s\n→ %s", resp.Status, location) } data, err = io.ReadAll(resp.Body)