Skip to content

Commit

Permalink
add: compat check bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
cfhamlet committed Oct 11, 2019
1 parent e02f56a commit 0b98a5a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/os_spage/validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ def check_datetime(instance):

@FormatChecker.cls_checks("url")
def simple_check_url(url):
b1 = ":"
b2 = "://"
if isinstance(url, bytes):
b1 = b":"
b2 = b"://"
if len(url) > 0:
t = url.find(":")
if t > 0 and url[t : t + 3] == "://":
t = url.find(b1)
if t > 0 and url[t : t + 3] == b2:
return True
return False

Expand Down

0 comments on commit 0b98a5a

Please sign in to comment.