mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Better error message when URL parsing fails
This commit is contained in:
parent
182d9b0d40
commit
5cbd9ef5da
@ -410,7 +410,10 @@ def urlnormalize(href):
|
|||||||
"""Convert a URL into normalized form, with all and only URL-unsafe
|
"""Convert a URL into normalized form, with all and only URL-unsafe
|
||||||
characters URL quoted.
|
characters URL quoted.
|
||||||
"""
|
"""
|
||||||
parts = urlparse(href)
|
try:
|
||||||
|
parts = urlparse(href)
|
||||||
|
except ValueError as e:
|
||||||
|
raise ValueError('Failed to parse the URL: %r with underlying error: %s' % (href, as_unicode(e)))
|
||||||
if not parts.scheme or parts.scheme == 'file':
|
if not parts.scheme or parts.scheme == 'file':
|
||||||
path, frag = urldefrag(href)
|
path, frag = urldefrag(href)
|
||||||
parts = ('', '', path, '', '', frag)
|
parts = ('', '', path, '', '', frag)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user