diff --git a/django/utils/html.py b/django/utils/html.py
index 33e2ee3..20ab895 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -106,9 +106,10 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
                         urlquote(middle, safe='/&=:;#?+'),  nofollow_attr,
                         trim_url(middle))
             if middle.startswith('http://') or middle.startswith('https://'):
+                middle = trim_url(middle) 
                 middle = '<a href="%s"%s>%s</a>' % (
                         urlquote(middle, safe='/&=:;#?+'), nofollow_attr,
-                        trim_url(middle))
+                        middle)
             if '@' in middle and not middle.startswith('www.') and \
                     not ':' in middle and simple_email_re.match(middle):
                 middle = '<a href="mailto:%s">%s</a>' % (middle, middle)
