added: serving missing.svg on error instead of an invalid image URL
This commit is contained in:
parent
1721db85a7
commit
787816d0ab
7 changed files with 263 additions and 57 deletions
|
@ -149,7 +149,7 @@ func PerformDeviantArtImageSearch(query, safe, lang string, page int) ([]ImageSe
|
|||
go func(imgSrc, resultURL, title string) {
|
||||
defer wg.Done()
|
||||
// Verify if the image URL is accessible
|
||||
if isValidImageURL(imgSrc, DeviantArtImageUserAgent, resultURL) {
|
||||
if DeviantArtisValidImageURL(imgSrc, DeviantArtImageUserAgent, resultURL) {
|
||||
resultsChan <- ImageSearchResult{
|
||||
Title: strings.TrimSpace(title),
|
||||
Full: imgSrc,
|
||||
|
@ -201,7 +201,7 @@ func buildDeviantArtSearchURL(query string, page int) string {
|
|||
}
|
||||
|
||||
// isValidImageURL checks if the image URL is accessible with the provided User-Agent
|
||||
func isValidImageURL(imgSrc, userAgent, referer string) bool {
|
||||
func DeviantArtisValidImageURL(imgSrc, userAgent, referer string) bool {
|
||||
client := &http.Client{}
|
||||
req, err := http.NewRequest("HEAD", imgSrc, nil)
|
||||
if err != nil {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue