openInBrowser opens a document's page on GitHub, or a link's URL. The page comes from the API, so the message shows it like gh issue view --web does. A link's URL is anything its author saved, so only an http(s) URL opens, and the message shows the whole URL, where text.DisplayURL would hide its por
(opts *ViewOptions, a client.Artifact)
| 167 | // and the message shows the whole URL, where text.DisplayURL would hide its |
| 168 | // port, query and fragment. |
| 169 | func openInBrowser(opts *ViewOptions, a client.Artifact) error { |
| 170 | target, shown := a.URL, text.DisplayURL(a.URL) |
| 171 | if a.Type == client.TypeLink { |
| 172 | u, ok := shared.HTTPURL(a.Body) |
| 173 | if !ok { |
| 174 | return fmt.Errorf("artifact %d doesn't link to an http(s) URL; `--web` only opens http(s) URLs", a.Number) |
| 175 | } |
| 176 | target, shown = u, u |
| 177 | } |
| 178 | |
| 179 | if opts.IO.IsStdoutTTY() { |
| 180 | fmt.Fprintf(opts.IO.ErrOut, "Opening %s in your browser.\n", shown) |
| 181 | } |
| 182 | return opts.Browser.Browse(target) |
| 183 | } |
| 184 | |
| 185 | // printRawArtifact prints key lines in a fixed order, then the body after a |
| 186 | // "--" line, like gh issue view. Null values print as empty fields, so every |
no test coverage detected