fixing bug #4 (thanks for the report)

This commit is contained in:
Lionel Dricot 2022-01-28 13:25:55 +01:00
parent 06b2e178fb
commit 69db426ab8
1 changed files with 15 additions and 9 deletions

View File

@ -395,9 +395,10 @@ class GeminiItem():
self.scheme = parsed.scheme self.scheme = parsed.scheme
if self.scheme in ["file","mailto"]: if self.scheme in ["file","mailto"]:
self.local = True self.local = True
self.host = None self.host = ""
h = self.url.split('/') #h = self.url.split('/')
self.host = h[0:len(h)-1] #self.host = h[0:len(h)-1]
self.port = None
self._cache_path = None self._cache_path = None
# file:// is 7 char # file:// is 7 char
if self.url.startswith("file://"): if self.url.startswith("file://"):
@ -649,8 +650,8 @@ class GeminiItem():
def up(self): def up(self):
pathbits = list(os.path.split(self.path.rstrip('/'))) pathbits = list(os.path.split(self.path.rstrip('/')))
# Don't try to go higher than root # Don't try to go higher than root or in config
if len(pathbits) == 1: if self.local or len(pathbits) == 1 :
return self return self
# Get rid of bottom component # Get rid of bottom component
pathbits.pop() pathbits.pop()
@ -666,9 +667,12 @@ class GeminiItem():
A thin wrapper around urlunparse which avoids inserting standard ports A thin wrapper around urlunparse which avoids inserting standard ports
into URLs just to keep things clean. into URLs just to keep things clean.
""" """
return urllib.parse.urlunparse((self.scheme, print("Derive :",self.host)
self.host if self.port == standard_ports[self.scheme] else self.host + ":" + str(self.port), if not self.port or self.port == standard_ports[self.scheme] :
path or self.path, "", query, "")) host = self.host
else:
host = self.host + ":" + str(self.port)
return urllib.parse.urlunparse((self.scheme,host,path or self.path, "", query, ""))
def absolutise_url(self, relative_url): def absolutise_url(self, relative_url):
""" """
@ -2110,7 +2114,9 @@ archives, which is a special historical list limited in size. It is similar to `
return True return True
def list_add_top(self,list,limit=0,truncate_lines=0): def list_add_top(self,list,limit=0,truncate_lines=0):
stri = self.gi.to_map_line().strip("\n") if not self.gi:
return
stri = "=> %s %s"%(self.gi.url,self.gi.url)
if list == "archives": if list == "archives":
stri += ", archived on " stri += ", archived on "
elif list == "history": elif list == "history":