hasUrls() may be true even if there are no URLs

Silences the error on https://forums.ankiweb.net/t/error-message-with-forvo/28529
This commit is contained in:
Damien Elmes 2023-03-22 16:24:50 +10:00
parent 77a45365cb
commit 516748c782

View File

@ -1294,7 +1294,11 @@ class EditorWebView(AnkiWebView):
return html_content, internal
# favour url if it's a local link
if mime.hasUrls() and mime.urls()[0].toString().startswith("file://"):
if (
mime.hasUrls()
and (urls := mime.urls())
and urls[0].toString().startswith("file://")
):
types = (self._processUrls, self._processImage, self._processText)
else:
types = (self._processImage, self._processUrls, self._processText)