kopia lustrzana https://gitlab.com/jaywink/federation
Impove the url matching regex.
rodzic
5dac605c4b
commit
ada8c20d39
|
@ -11,10 +11,9 @@ TAG_PATTERN = re.compile(r'(#[\w\-]+)([)\]_!?*%/.,;\s]+\s*|\Z)', re.UNICODE)
|
||||||
# This will match non matching braces. I don't think it's an issue.
|
# This will match non matching braces. I don't think it's an issue.
|
||||||
MENTION_PATTERN = re.compile(r'(@\{?(?:[\w\-. \u263a-\U0001f645]*; *)?[\w]+@[\w\-.]+\.[\w]+}?)', re.UNICODE)
|
MENTION_PATTERN = re.compile(r'(@\{?(?:[\w\-. \u263a-\U0001f645]*; *)?[\w]+@[\w\-.]+\.[\w]+}?)', re.UNICODE)
|
||||||
# based on https://stackoverflow.com/a/6041965
|
# based on https://stackoverflow.com/a/6041965
|
||||||
URL_PATTERN = re.compile(r'((?:(?:https?|ftp)://|\b(?:\w+\.)+\w+)(?:(?:[^\s()<>]+|\((?:[^\s()<>]+|(?:\([^\s()<>]+\)))?\))+(?:\((?:[^\s()<>]+|(?:\(?:[^\s()<>]+\)))?\)|[^\s`!()\[\]{};:\'".,<>?«»“”‘’]))?)',
|
URL_PATTERN = re.compile(r'((?:(?:https?|ftp)://|^|(?<=[("<\s]))+(?:[\w\-]+(?:(?:\.[\w\-]+)+))(?:[\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-]))',
|
||||||
re.UNICODE)
|
re.UNICODE)
|
||||||
|
|
||||||
|
|
||||||
def decode_if_bytes(text):
|
def decode_if_bytes(text):
|
||||||
try:
|
try:
|
||||||
return text.decode("utf-8")
|
return text.decode("utf-8")
|
||||||
|
|
Ładowanie…
Reference in New Issue