code cleanup

This commit is contained in:
stefanodvx 2025-04-24 12:20:35 +02:00
parent 917be1687f
commit 5336968e05
34 changed files with 193 additions and 115 deletions

View file

@ -2,10 +2,13 @@ package ext
import (
"fmt"
"govd/models"
"net/url"
"strings"
"sync"
"govd/models"
"github.com/pkg/errors"
)
var (
@ -37,7 +40,7 @@ func CtxByURL(urlStr string) (*models.DownloadContext, error) {
for redirectCount <= maxRedirects {
parsedURL, err := url.Parse(currentURL)
if err != nil {
return nil, fmt.Errorf("invalid URL: %v", err)
return nil, fmt.Errorf("invalid URL: %w", err)
}
host := strings.TrimPrefix(parsedURL.Host, "www.")
@ -87,7 +90,7 @@ func CtxByURL(urlStr string) (*models.DownloadContext, error) {
return nil, err
}
if response.URL == "" {
return nil, fmt.Errorf("no URL found in response")
return nil, errors.New("no URL found in response")
}
currentURL = response.URL