File tree Expand file tree Collapse file tree 1 file changed +11
-7
lines changed
Expand file tree Collapse file tree 1 file changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -147,13 +147,17 @@ def is_image_url(url: str, **kwargs) -> str:
147147 bool
148148 Whether the URL is a valid image URL.
149149 """
150- if url .startswith ("https://gyazo.com" ) or url .startswith ("http://gyazo.com" ):
151- # gyazo support
152- url = re .sub (
153- r"(http[s]?:\/\/)((?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)" ,
154- r"\1i.\2.png" ,
155- url ,
156- )
150+ try :
151+ result = parse .urlparse (url )
152+ if result .netloc == 'gyazo.com' and result .scheme in ['http' , 'https' ]:
153+ # gyazo support
154+ url = re .sub (
155+ r"(https?://)((?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|%[0-9a-fA-F][0-9a-fA-F])+)" ,
156+ r"\1i.\2.png" ,
157+ url ,
158+ )
159+ except ValueError :
160+ pass
157161
158162 return parse_image_url (url , ** kwargs )
159163
You can’t perform that action at this time.
0 commit comments