Opened 9 years ago

Closed 9 years ago

#4657 closed (fixed)

urlizetrunc filter appending elipsis to uris of exactly the truncate length

Reported by: Chris Beaven Owned by: Adrian Holovaty
Component: Template system Version: master
Severity: Keywords: urlize html utils
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

>>> from django.template.defaultfilters import urlizetrunc
>>> uri = 'http://31characteruri.com/test/'
>>> len(uri)
31
>>> urlizetrunc(uri, 31)
'<a href="http://31characteruri.com/test/" rel="nofollow">http://31characteruri.com/test/...</a>'

The attached patch addresses this. Also, if the URI does need truncating, this patch changes it so that the truncation length is - 3 to adjust for the addition of the 3 elipsis characters (see the test in the patch for a better explanation).

Attachments (2)

urlize_trunc.patch (1.5 KB) - added by Chris Beaven 9 years ago.
urlize_trunc.2.patch (2.6 KB) - added by Chris Beaven 9 years ago.
with tests this time

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by Chris Beaven

Attachment: urlize_trunc.patch added

Changed 9 years ago by Chris Beaven

Attachment: urlize_trunc.2.patch added

with tests this time

comment:1 Changed 9 years ago by Simon G. <dev@…>

Triage Stage: UnreviewedReady for checkin

comment:2 Changed 9 years ago by Malcolm Tredinnick

Resolution: fixed
Status: newclosed

(In [5513]) Fixed #4657 -- Fixed an error in an edge case of the urlizetrunc filter.
Thanks, SmileyChris.

Note: See TracTickets for help on using tickets.
Back to Top