Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow tilde in URL (fixes #3057) #3067

Merged
merged 4 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

### Fixed

- Fix tilde character (`~`) not included in link regex when printing to console https://github.com/Textualize/rich/issues/3057

## [13.5.0] - 2023-07-29

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The following people have contributed to the development of Rich:
- [Clément Robert](https://github.com/neutrinoceros)
- [Brian Rutledge](https://github.com/bhrutledge)
- [Tushar Sadhwani](https://github.com/tusharsadhwani)
- [Luca Salvarani](https://github.com/LukeSavefrogs)
- [Paul Sanders](https://github.com/sanders41)
- [Tim Savage](https://github.com/timsavage)
- [Anthony Shaw](https://github.com/tonybaloney)
Expand Down
2 changes: 1 addition & 1 deletion rich/highlighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class ReprHighlighter(RegexHighlighter):
r"(?P<number>(?<!\w)\-?[0-9]+\.?[0-9]*(e[-+]?\d+?)?\b|0x[0-9a-fA-F]*)",
r"(?P<path>\B(/[-\w._+]+)*\/)(?P<filename>[-\w._+]*)?",
r"(?<![\\\w])(?P<str>b?'''.*?(?<!\\)'''|b?'.*?(?<!\\)'|b?\"\"\".*?(?<!\\)\"\"\"|b?\".*?(?<!\\)\")",
r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#]*)",
r"(?P<url>(file|https|http|ws|wss)://[-0-9a-zA-Z$_+!`(),.?/;:&=%#~]*)",
),
]

Expand Down
3 changes: 3 additions & 0 deletions tests/test_highlighter.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ def test_wrong_type():
(" https://example.org ", [Span(1, 20, "repr.url")]),
(" 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")]),
(" http://example.org/index.html?param1=value1 ", [Span(31, 37, 'repr.attrib_name'), Span(38, 44, 'repr.attrib_value'), Span(1, 44, "repr.url")]),
(" http://example.org/~folder ", [Span(1, 27, "repr.url")]),
("No place like 127.0.0.1", [Span(14, 23, "repr.ipv4")]),
("''", [Span(0, 2, "repr.str")]),
("'hello'", [Span(0, 7, "repr.str")]),
Expand Down
Loading