fix: tui mode handling of remote urls (#744)

This commit is contained in:
Glauber Santana 2025-04-09 10:18:13 -03:00 committed by GitHub
commit d2e04adbfe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -327,7 +327,11 @@ func executeCLI(cmd *cobra.Command, src *source, w io.Writer) error {
}
return nil
case tui || cmd.Flags().Changed("tui"):
return runTUI(src.URL, content)
path := ""
if !isURL(src.URL) {
path = src.URL
}
return runTUI(path, content)
default:
if _, err = fmt.Fprint(w, out); err != nil {
return fmt.Errorf("unable to write to writer: %w", err)

5
url.go
View file

@ -79,3 +79,8 @@ func gitlabReadmeURL(path string) *url.URL {
u, _ := url.Parse(gitlabURL.String())
return u.JoinPath(path)
}
func isURL(path string) bool {
_, err := url.ParseRequestURI(path)
return err == nil && strings.Contains(path, "://")
}