Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty subdomain case in template tag is not correctly processed #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion subdomains/templatetags/subdomainurls.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def url(context, view, subdomain=UNSET, *args, **kwargs):
subdomain = getattr(request, 'subdomain', None)
else:
subdomain = None
elif subdomain is '':
elif not subdomain:
subdomain = None

return reverse(view, subdomain=subdomain, args=args, kwargs=kwargs)
8 changes: 8 additions & 0 deletions subdomains/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,14 @@ def test_without_subdomain(self):
rendered = template.render(context).strip()
self.assertEqual(rendered, 'http://%s/' % self.DOMAIN)

def test_with_empty_subdomain(self):
defaults = {'view': 'home'}
template = self.make_template('{% url view subdomain="" %}')

context = Context(defaults)
rendered = template.render(context).strip()
self.assertEqual(rendered, 'http://%s/' % self.DOMAIN)

def test_with_subdomain(self):
defaults = {'view': 'home'}
template = self.make_template('{% url view subdomain=subdomain %}')
Expand Down