mirror of
https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
synced 2025-11-03 20:27:54 +00:00
Added check for valid url format for LFRequest init
This commit is contained in:
@@ -23,8 +23,19 @@ class LFRequest:
|
|||||||
default_headers = {
|
default_headers = {
|
||||||
'Accept': 'application/json'}
|
'Accept': 'application/json'}
|
||||||
|
|
||||||
def __init__(self, url):
|
def __init__(self, url, uri=None):
|
||||||
self.requested_url = url
|
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
|
# request first url on stack
|
||||||
def formPost(self, show_error=True):
|
def formPost(self, show_error=True):
|
||||||
|
|||||||
Reference in New Issue
Block a user