mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
truncate_cells_html now affects URLs too, refs #1805
This commit is contained in:
parent
ff9c87197d
commit
d0737e4de5
8 changed files with 68 additions and 14 deletions
|
|
@ -626,3 +626,23 @@ def test_tilde_encoding(original, expected):
|
|||
assert actual == expected
|
||||
# And test round-trip
|
||||
assert original == utils.tilde_decode(actual)
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"url,length,expected",
|
||||
(
|
||||
("https://example.com/", 5, "http…"),
|
||||
("https://example.com/foo/bar", 15, "https://exampl…"),
|
||||
("https://example.com/foo/bar/baz.jpg", 30, "https://example.com/foo/ba….jpg"),
|
||||
# Extensions longer than 4 characters are not treated specially:
|
||||
("https://example.com/foo/bar/baz.jpeg2", 30, "https://example.com/foo/bar/b…"),
|
||||
(
|
||||
"https://example.com/foo/bar/baz.jpeg2",
|
||||
None,
|
||||
"https://example.com/foo/bar/baz.jpeg2",
|
||||
),
|
||||
),
|
||||
)
|
||||
def test_truncate_url(url, length, expected):
|
||||
actual = utils.truncate_url(url, length)
|
||||
assert actual == expected
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue