From bc6499e213b3ce02867e8d5c3d075bafc52d5e3d Mon Sep 17 00:00:00 2001 From: Logan Lipke Date: Fri, 5 Jun 2020 13:07:06 -0700 Subject: [PATCH] Added check for valid url format for LFRequest init --- py-json/LANforge/LFRequest.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/py-json/LANforge/LFRequest.py b/py-json/LANforge/LFRequest.py index cd6a1049..24213ae5 100644 --- a/py-json/LANforge/LFRequest.py +++ b/py-json/LANforge/LFRequest.py @@ -23,8 +23,19 @@ class LFRequest: default_headers = { 'Accept': 'application/json'} - def __init__(self, url): - self.requested_url = url + def __init__(self, url, uri=None): + if "http://" not in url or "https://" not in url: + print("No http:// or https:// found, prepending http://") + url = "http://" + url + if not url.endswith('/') and not uri.startswith('/'): + url += '/' + if uri is not None: + self.requested_url = url + uri + if self.requested_url.find('//'): + protopos = self.requested_url.find("://") + self.requested_url = self.requested_url[:protopos + 2] + self.requested_url[protopos + 2:].replace("//", "/") + + # request first url on stack def formPost(self, show_error=True):