Opened 17 years ago

Closed 17 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: dev
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: no UI/UX: no

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 17 years ago.
urlize_trunc.2.patch (2.6 KB ) - added by Chris Beaven 17 years ago.
with tests this time

Download all attachments as: .zip

Change History (4)

by Chris Beaven, 17 years ago

Attachment: urlize_trunc.patch added

by Chris Beaven, 17 years ago

Attachment: urlize_trunc.2.patch added

with tests this time

comment:1 by Simon G. <dev@…>, 17 years ago

Triage Stage: UnreviewedReady for checkin

comment:2 by Malcolm Tredinnick, 17 years ago

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