diff --git a/qt/aqt/editor.py b/qt/aqt/editor.py
index 073696c9a..7d081cde4 100644
--- a/qt/aqt/editor.py
+++ b/qt/aqt/editor.py
@@ -758,7 +758,9 @@ require("anki/ui").loaded.then(() => require("anki/NoteEditor").instances[0].too
def urlToLink(self, url: str) -> str | None:
fname = self.urlToFile(url)
if not fname:
- return None
+ return '{}'.format(
+ url, html.escape(urllib.parse.unquote(url))
+ )
return self.fnameToLink(fname)
def fnameToLink(self, fname: str) -> str:
@@ -1261,7 +1263,7 @@ class EditorWebView(AnkiWebView):
url = qurl.toString()
# chrome likes to give us the URL twice with a \n
url = url.splitlines()[0]
- buf += self.editor.urlToLink(url) or ""
+ buf += self.editor.urlToLink(url)
return buf
@@ -1279,16 +1281,9 @@ class EditorWebView(AnkiWebView):
if extended and token.startswith("data:image/"):
processed.append(self.editor.inlinedImageToLink(token))
elif extended and self.editor.isURL(token):
- # if the user is pasting an image or sound link, convert it to local
+ # if the user is pasting an image or sound link, convert it to local, otherwise paste as a hyperlink
link = self.editor.urlToLink(token)
- if link:
- processed.append(link)
- else:
- # not media; add it as a normal link
- link = '{}'.format(
- token, html.escape(urllib.parse.unquote(token))
- )
- processed.append(link)
+ processed.append(link)
else:
token = html.escape(token).replace("\t", " " * 4)
# if there's more than one consecutive space,