From f591471cf005062c9068f5ac348c01aec4ca13ef Mon Sep 17 00:00:00 2001 From: subrat-lima Date: Thu, 15 Aug 2024 21:21:18 +0530 Subject: [PATCH] Fix [BUG] @ breaks highlighting in hyperlink #3327 Changes - 1. Added '@' in rich.highlighter:ReprHighlighter url regex pattern. 2. Added a test case in test_highlighter for the url with '@'. --- rich/highlighter.py | 2 +- tests/test_highlighter.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/rich/highlighter.py b/rich/highlighter.py index 27714b25..e4c462e2 100644 --- a/rich/highlighter.py +++ b/rich/highlighter.py @@ -98,7 +98,7 @@ class ReprHighlighter(RegexHighlighter): r"(?P(?\B(/[-\w._+]+)*\/)(?P[-\w._+]*)?", r"(?b?'''.*?(?(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)", + r"(?P(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~@]*)", ), ] diff --git a/tests/test_highlighter.py b/tests/test_highlighter.py index 30851cf7..d1992827 100644 --- a/tests/test_highlighter.py +++ b/tests/test_highlighter.py @@ -134,6 +134,7 @@ highlight_tests = [ (" http://example.org ", [Span(1, 19, "repr.url")]), (" http://example.org/index.html ", [Span(1, 30, "repr.url")]), (" http://example.org/index.html#anchor ", [Span(1, 37, "repr.url")]), + ("https://www.youtube.com/@LinusTechTips", [Span(0, 38, "repr.url")]), ( " http://example.org/index.html?param1=value1 ", [