mirror of
https://github.com/simonw/datasette.git
synced 2026-06-06 09:07:00 +02: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
|
|
@ -1167,3 +1167,13 @@ def resolve_routes(routes, path):
|
|||
if match is not None:
|
||||
return match, view
|
||||
return None, None
|
||||
|
||||
|
||||
def truncate_url(url, length):
|
||||
if (not length) or (len(url) <= length):
|
||||
return url
|
||||
bits = url.rsplit(".", 1)
|
||||
if len(bits) == 2 and 1 <= len(bits[1]) <= 4 and "/" not in bits[1]:
|
||||
rest, ext = bits
|
||||
return rest[: length - 1 - len(ext)] + "…." + ext
|
||||
return url[: length - 1] + "…"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue