forked from superdesk/superdesk-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix urls creation from richtext [STTNHUB-252] (superdesk#2481)
* Fix urls creation from richtext * add test * reformat code via black
- Loading branch information
1 parent
527ecb0
commit ce3862e
Showing
2 changed files
with
13 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -141,7 +141,7 @@ def test_convert_plain_text_to_html(self): | |
test_strings = [ | ||
["plain text", "<p>plain text</p>"], | ||
["email me at [email protected]", '<p>email me at <a href="mailto:[email protected]">[email protected]</a></p>'], | ||
["find me on foobar.com", '<p>find me on <a href="foobar.com" target="_blank">foobar.com</a></p>'], | ||
["find me on foobar.com", '<p>find me on <a href="https://foobar.com" target="_blank">foobar.com</a></p>'], | ||
[ | ||
"https://www.foobar.com", | ||
'<p><a href="https://www.foobar.com" target="_blank">https://www.foobar.com</a></p>', | ||
|
@@ -152,7 +152,7 @@ def test_convert_plain_text_to_html(self): | |
"https://www.foobar.com/test?one=two&three=4</a></p>", | ||
], | ||
["https://foobar.com", '<p><a href="https://foobar.com" target="_blank">https://foobar.com</a></p>'], | ||
["www.foobar.com", '<p><a href="www.foobar.com" target="_blank">www.foobar.com</a></p>'], | ||
["www.foobar.com", '<p><a href="https://www.foobar.com" target="_blank">www.foobar.com</a></p>'], | ||
[ | ||
"""Foo Bar | ||
|
@@ -164,8 +164,12 @@ def test_convert_plain_text_to_html(self): | |
"<p>Foo Bar PTY LTD</p>" | ||
"<p>Ph +61 23456789</p>" | ||
'<p>Email: <a href="mailto:[email protected]">[email protected]</a> ' | ||
'Website: <a href="www.foobar.com" target="_blank">www.foobar.com</a></p>', | ||
'Website: <a href="https://www.foobar.com" target="_blank">www.foobar.com</a></p>', | ||
], | ||
] | ||
for tests in test_strings: | ||
self.assertEqual(text_utils.plain_text_to_html(tests[0]), tests[1]) | ||
|
||
self.assertEqual( | ||
text_utils.plain_text_to_html("foo.com"), '<p><a href="https://foo.com" target="_blank">foo.com</a></p>' | ||
) |