Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

Commit

Permalink
don't absolutify if the url already looks absolute (bug 684128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeff Balogh committed Sep 2, 2011
1 parent 1b54fb7 commit 64ca967
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion apps/amo/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,10 @@ def json(s):
@register.filter
def absolutify(url):
"""Takes a URL and prepends the SITE_URL"""
return settings.SITE_URL + url
if url.startswith('http'):
return url
else:
return settings.SITE_URL + url


@register.filter
Expand Down
6 changes: 6 additions & 0 deletions apps/amo/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,3 +433,9 @@ def test_jinja_trans_monkeypatch():
render('{% trans come_on=1 %}% (come_on)s{% endtrans %}')
render('{% trans come_on=1 %}%(come_on){% endtrans %}')
render('{% trans come_on=1 %}%(come_on)z{% endtrans %}')


def test_absolutify():
eq_(helpers.absolutify('/woo'), settings.SITE_URL + '/woo')
eq_(helpers.absolutify('https://addons.mozilla.org'),
'https://addons.mozilla.org')

0 comments on commit 64ca967

Please sign in to comment.