summary refs log tree commit diff
path: root/protocol
diff options
context:
space:
mode:
authorZach DeCook <zachdecook@librem.one>2022-12-24 07:24:28 -0500
committerZach DeCook <zachdecook@librem.one>2022-12-24 07:24:28 -0500
commit09b393bf5de74e11a4a46ab4c697175e4ca8a480 (patch)
tree9e1ad99504d99578aea58f90363fc3007124cd18 /protocol
parent1a2eaf6f305bd95debc0409639627bcb9cb8e6fc (diff)
downloadbrowset-09b393bf5de74e11a4a46ab4c697175e4ca8a480.tar.gz
browset: Support clicking buttons (relative path)
Diffstat (limited to 'protocol')
-rw-r--r--protocol/gemini.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/protocol/gemini.py b/protocol/gemini.py
index c55e523..ec51b7c 100644
--- a/protocol/gemini.py
+++ b/protocol/gemini.py
@@ -2,6 +2,19 @@ import socket
 import ssl
 
 class GeminiProtocol():
+    def relativeURL(path, prevurl):
+        if path.startswith("/"):
+            url = '/'.join(prevurl.split("/")[0:3])+path
+        else:
+            base = prevurl
+            if base.count('/') >= 3:
+                base = '/'.join(prevurl.split('/')[0:-1])
+            while path.startswith("../"):
+                base = '/'.join(base.split('/')[0:-1])
+                path = path.replace("../","",1)
+            url = base + '/' + path
+        return url
+
     def get(url):
         hostname = _gethostname(url)
         try: