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 @@ -152,13 +152,17 @@ def is_image_url(url: str, **kwargs) -> str:
152152 bool
153153 Whether the URL is a valid image URL.
154154 """
155- if url .startswith ("https://gyazo.com" ) or url .startswith ("http://gyazo.com" ):
156- # gyazo support
157- url = re .sub (
158- r"(http[s]?:\/\/)((?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|(?:%[0-9a-fA-F][0-9a-fA-F]))+)" ,
159- r"\1i.\2.png" ,
160- url ,
161- )
155+ try :
156+ result = parse .urlparse (url )
157+ if result .netloc == 'gyazo.com' and result .scheme in ['http' , 'https' ]:
158+ # gyazo support
159+ url = re .sub (
160+ r"(https?://)((?:[a-zA-Z]|[0-9]|[$-_@.&+]|[!*(),]|%[0-9a-fA-F][0-9a-fA-F])+)" ,
161+ r"\1i.\2.png" ,
162+ url ,
163+ )
164+ except ValueError :
165+ pass
162166
163167 return parse_image_url (url , ** kwargs )
164168
You can’t perform that action at this time.
0 commit comments