Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ depending on the type of link:
from message content such as `#**announce>terminal releases**`)
* the active narrow will be changed to the stream or topic (from version 0.6.0)
- *External links* (eg. a website, file from a website)
* no internal action is supported at this time
* open in browser if it is a website, otherwise no internal action is supported at this time

Any method supported by your terminal emulator to select and copy text should
also be suitable to extract these links.
Expand Down
9 changes: 6 additions & 3 deletions tests/ui_tools/test_buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,12 @@ def test_update_widget(
"link",
"handle_narrow_link_called",
"process_media_called",
"open_in_browser_called",
],
[
(SERVER_URL + "/#narrow/stream/1-Stream-1", True, False),
(SERVER_URL + "/user_uploads/some/path/image.png", False, True),
("https://foo.com", False, False),
(SERVER_URL + "/#narrow/stream/1-Stream-1", True, False, False),
(SERVER_URL + "/user_uploads/some/path/image.png", False, True, False),
("https://foo.com", False, False, True),
],
ids=[
"internal_narrow_link",
Expand All @@ -606,6 +607,7 @@ def test_handle_link(
link: str,
handle_narrow_link_called: bool,
process_media_called: bool,
open_in_browser_called: bool,
) -> None:
self.controller.model.server_url = SERVER_URL
self.handle_narrow_link = mocker.patch(MSGLINKBUTTON + ".handle_narrow_link")
Expand All @@ -617,6 +619,7 @@ def test_handle_link(

assert self.handle_narrow_link.called == handle_narrow_link_called
assert self.process_media.called == process_media_called
assert self.controller.open_in_browser.called == open_in_browser_called

@pytest.mark.parametrize(
"stream_data, expected_response",
Expand Down
2 changes: 2 additions & 0 deletions zulipterminal/ui_tools/buttons.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ def handle_link(self, *_: Any) -> None:
if self.controller.is_any_popup_open():
self.controller.exit_popup()
process_media(self.controller, self.link)
elif self.link.startswith(("https://", "http://")):
self.controller.open_in_browser(self.link)
Comment on lines +472 to +473
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be useful to define the protocols we support somewhere as a constant rather than inline here.


@staticmethod
def _decode_stream_data(encoded_stream_data: str) -> DecodedStream:
Expand Down