Adding default protocol to URLs typed without one

This commit is contained in:
Fierelier 2021-03-20 21:13:42 +01:00
parent 184d9697d8
commit 5abb9e13db
2 changed files with 8 additions and 0 deletions

View File

@ -3,6 +3,8 @@
home = https://example.com
# User agent, used to identify your browser to a website
useragent = BirdyNet/$VER ($OS)
# Which protocol to use when none is given in the address bar
defaultProtocol = https
[accessibility]
# Which background color (CSS color) should be chosen for websites? "default" for system's default. "white" is recommended for compatibility.

View File

@ -164,6 +164,12 @@ class browserWindow(QMainWindow):
self.cTaskLock.acquire()
self.cDownloadId += 1
url = self.cUrlBar.text().replace(" ","%20") # dirty
urlParsed = parseUrl(url)
if urlParsed["protocol"] == "":
while len(url) > 0 and url[0] == "/":
url = url[1:]
url = config["default"]["defaultProtocol"]+ "://" +url
self.cUrlBar.setText(url)
threading.Thread(target=downloadPage, args=(self,self.cDownloadId,url,[("User-Agent",self.cUserAgent)])).start()
self.cTaskLock.release()
self.cDoc.setFocus()