Browse Source

Update URL Validation Regex to Support IP Addresses and Port Numbers (#1233)

Juanan Pereira 1 year ago
parent
commit
819650a254
1 changed files with 1 additions and 2 deletions
  1. 1 2
      embedchain/loaders/json.py

+ 1 - 2
embedchain/loaders/json.py

@@ -36,8 +36,7 @@ class JSONReader:
         return ["\n".join(useful_lines)]
 
 
-VALID_URL_PATTERN = "^https:\/\/[0-9A-Za-z]+(\.[0-9A-Za-z]+)*\/[0-9A-Za-z_\/]*\.json$"
-
+VALID_URL_PATTERN = "^https?://(?:www\.)?(?:\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|[a-zA-Z0-9.-]+)(?::\d+)?/(?:[^/\s]+/)*[^/\s]+\.json$"
 
 class JSONLoader(BaseLoader):
     @staticmethod