browser.py

Working through the exercises at browser.engineering
git clone https://git.sr.ht/~jbauer/browser.py
Log | Files | Refs | README | LICENSE

commit 09431ff1b1110ccdd0908ec891e2aba25feafa2b
parent d5f4469c0d253755fb6b589d20259b886fea2c91
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Tue, 21 Feb 2023 18:53:43 -0500

Better url support

Diffstat:
Mbrowser.py | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/browser.py b/browser.py @@ -402,8 +402,9 @@ def request(url): scheme,url = url.split("://", 1) assert scheme in ["http", "https"], \ "Unknown scheme {}".format(scheme) - host, path = url.split("/", 1) - path = "/" + path + url_components = url.split("/", 1) + host = url_components[0] + path = "/" + (url_components[1] if len(url_components) > 2 else "") s = socket.socket( family=socket.AF_INET, @@ -474,5 +475,6 @@ if __name__ == "__main__": import sys if len(sys.argv) < 2: url = "http://www.paritybit.ca/meta.html" else: url = sys.argv[1] + # if url.endswith("/"): url += "index.html" Browser().load(url) tkinter.mainloop()