mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #7345 -- When normalising the URLField form field, attach a trailing
slash when only a host (no path) is given. Thanks, jpwatts. git-svn-id: http://code.djangoproject.com/svn/django/trunk@8089 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -7,6 +7,7 @@ import datetime
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
import urlparse
|
||||
try:
|
||||
from cStringIO import StringIO
|
||||
except ImportError:
|
||||
@@ -539,6 +540,9 @@ class URLField(RegexField):
|
||||
# If no URL scheme given, assume http://
|
||||
if value and '://' not in value:
|
||||
value = u'http://%s' % value
|
||||
# If no URL path given, assume /
|
||||
if value and not urlparse.urlsplit(value).path:
|
||||
value += '/'
|
||||
value = super(URLField, self).clean(value)
|
||||
if value == u'':
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user