happy new year
This commit is contained in:
+14
-2
@@ -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 == '':
|
||||
|
||||
Reference in New Issue
Block a user