From 0b98a5aef515d2d8f752995f67384a96803a97f4 Mon Sep 17 00:00:00 2001 From: Ozzy Date: Fri, 11 Oct 2019 21:13:57 +0800 Subject: [PATCH] add: compat check bytes --- src/os_spage/validator.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/os_spage/validator.py b/src/os_spage/validator.py index 9042b05..77e4dee 100644 --- a/src/os_spage/validator.py +++ b/src/os_spage/validator.py @@ -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