From 70cd3f655704be25fbfd3ab0d5dfbd085a371799 Mon Sep 17 00:00:00 2001 From: dece Date: Fri, 26 Feb 2021 15:36:56 +0100 Subject: [PATCH] browser: basically handle HTTP(S) links --- bebop/browser.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bebop/browser.py b/bebop/browser.py index e471776..0787e3c 100644 --- a/bebop/browser.py +++ b/bebop/browser.py @@ -3,6 +3,7 @@ import curses.ascii import curses.textpad import os from math import inf +from webbrowser import open_new_tab from bebop.colors import ColorPair, init_colors from bebop.command_line import (CommandLine, EscapeCommandInterrupt, @@ -189,6 +190,8 @@ class Browser: if join: url = join_url(self.current_url, url) self.open_gemini_url(sanitize_url(url), redirections) + elif parts.scheme.startswith("http"): + self.open_web_url(url) else: self.set_status_error(f"Protocol {parts.scheme} not supported.") @@ -448,3 +451,8 @@ class Browser: """Go back in history if possible.""" if self.history.has_links(): self.open_gemini_url(self.history.pop(), history=False) + + def open_web_url(self, url): + """Open a Web URL. Currently relies in Python's webbrowser module.""" + self.set_status(f"Opening {url}") + open_new_tab(url)