feat: better url validation:
- Do not accept redirects. Usually on yt at least, redirect means the link is invalid. Hence, it redirects to the home page. - This is tested and it works well. trust. Signed-off-by: HeshamTB <hishaminv@gmail.com>
This commit is contained in:
parent
b88ca836ef
commit
13269a7b84
@ -8,6 +8,6 @@
|
|||||||
<button>Try Again
|
<button>Try Again
|
||||||
<!-- <a class="htmx-indicator" href="#" aria-busy="true"></a> -->
|
<!-- <a class="htmx-indicator" href="#" aria-busy="true"></a> -->
|
||||||
</button>
|
</button>
|
||||||
<mark>Internal Error. Try Again later</mark>
|
<strong>Internal Error. Try Again later</strong>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
6
yt.go
6
yt.go
@ -31,7 +31,11 @@ func isValidURL(data string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
httpClient := &http.Client{}
|
httpClient := &http.Client{
|
||||||
|
CheckRedirect: func(req *http.Request, via []*http.Request) error {
|
||||||
|
return http.ErrUseLastResponse
|
||||||
|
},
|
||||||
|
}
|
||||||
resp, err := httpClient.Get(data)
|
resp, err := httpClient.Get(data)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user