mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
Set to use a regular expression to remove the server name because
it is less prone to break in future updates.
This commit is contained in:
parent
7061aac16d
commit
2f174b40a6
1 changed files with 3 additions and 2 deletions
|
@ -4,6 +4,7 @@
|
||||||
import dataclasses
|
import dataclasses
|
||||||
import json
|
import json
|
||||||
import math
|
import math
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
from typing import Any, Callable, List, Optional, Sequence, Tuple
|
from typing import Any, Callable, List, Optional, Sequence, Tuple
|
||||||
|
|
||||||
|
@ -70,14 +71,14 @@ class AnkiWebPage(QWebEnginePage): # type: ignore
|
||||||
def javaScriptConsoleMessage(self, level, msg, line, srcID):
|
def javaScriptConsoleMessage(self, level, msg, line, srcID):
|
||||||
# not translated because console usually not visible,
|
# not translated because console usually not visible,
|
||||||
# and may only accept ascii text
|
# and may only accept ascii text
|
||||||
srcID = srcID.replace(AnkiWebView.webBundlePath("/"), "")
|
srcID = re.sub(r"(?mi).+://[^/]+", "", srcID)
|
||||||
if level == QWebEnginePage.InfoMessageLevel:
|
if level == QWebEnginePage.InfoMessageLevel:
|
||||||
level = "info"
|
level = "info"
|
||||||
elif level == QWebEnginePage.WarningMessageLevel:
|
elif level == QWebEnginePage.WarningMessageLevel:
|
||||||
level = "warning"
|
level = "warning"
|
||||||
elif level == QWebEnginePage.ErrorMessageLevel:
|
elif level == QWebEnginePage.ErrorMessageLevel:
|
||||||
level = "error"
|
level = "error"
|
||||||
buf = "JS %(t)s /%(f)s:%(a)d %(b)s" % dict(
|
buf = "JS %(t)s %(f)s:%(a)d %(b)s" % dict(
|
||||||
t=level, a=line, f=srcID, b=msg + "\n"
|
t=level, a=line, f=srcID, b=msg + "\n"
|
||||||
)
|
)
|
||||||
# ensure we don't try to write characters the terminal can't handle
|
# ensure we don't try to write characters the terminal can't handle
|
||||||
|
|
Loading…
Reference in a new issue