From 4e59993b99f21a9b1a614a7f2f219e8064d9bc4a Mon Sep 17 00:00:00 2001 From: Luxferre Date: Thu, 1 Jan 2026 00:07:59 +0200 Subject: [PATCH] happy new year --- app/bro.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/app/bro.py b/app/bro.py index 474e87b..481c31e 100644 --- a/app/bro.py +++ b/app/bro.py @@ -2,6 +2,7 @@ # Usage: from app.bro import DeckBro # Created by Luxferre in 2025-2026, released into public domain +import re from deck.pager import print_paged from deck.input import input, input_multi from deck.menu import menu @@ -9,7 +10,7 @@ from deck.http import http_fetch, http_set_ua from deck.text import DeckText class DeckBro: - def __init__(self, start_url=None): + def __init__(self, start_url=''): self.history = [] self.rendered_pages = [] self.history_pos = 0 # always refers to the current slot @@ -105,8 +106,19 @@ class DeckBro: do_new_display = False def go(self, url=None, update_history=True): + base_url = '' + current_url = self.url + match = re.search(r'^(https?://[^/]+)', current_url) + if match: + base_url = match.group(1) if url: - self.url = url.strip() + new_url = url.strip() + if current_url != '' and not new_url.lower().startswith('http'): + if new_url.startswith('/'): + new_url = base_url + new_url + else: + new_url = current_url + '/' + new_url + self.url = re.sub(r'([^:])//+', r'\1/', new_url) status, pagetext = http_fetch(self.url) if status != 200: if pagetext == '':