Skip to content

Commit

Permalink
Merge pull request #464 from liberapay/widgets-no-redirect
Browse files Browse the repository at this point in the history
Don't redirect widget requests to canonical URL
  • Loading branch information
Changaco authored Dec 23, 2016
2 parents 71485ce + 332ae17 commit ee6f42e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions liberapay/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@


def get_participant(state, restrict=True, redirect_stub=True, allow_member=False,
block_suspended_user=False):
block_suspended_user=False, redirect_canon=True):
"""Given a Request, raise Response or return Participant.
If restrict is True then we'll restrict access to owners and admins.
Expand Down Expand Up @@ -59,7 +59,7 @@ def get_participant(state, restrict=True, redirect_stub=True, allow_member=False
if participant is None or participant.kind == 'community':
raise response.error(404)

if request.method in ('GET', 'HEAD'):
if redirect_canon and request.method in ('GET', 'HEAD'):
if slug != participant.username:
canon = '/' + participant.username + request.line.uri[len(slug)+1:]
raise response.redirect(canon)
Expand Down
2 changes: 1 addition & 1 deletion www/%username/widgets/%type.spt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ t = request.path['type']
if t not in ('giving.js', 'receiving.js'):
raise response.error(400)

participant = get_participant(state, restrict=False)
participant = get_participant(state, restrict=False, redirect_canon=False)

if participant.hide_giving and t != 'receiving.js' or \
participant.hide_receiving and t != 'giving.js':
Expand Down
2 changes: 1 addition & 1 deletion www/%username/widgets/button.js.spt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ICON = include_svg(ICON, 16, 16)

[---]

participant = get_participant(state, restrict=False)
participant = get_participant(state, restrict=False, redirect_canon=False)

response.headers[b'Cache-Control'] = b'public, max-age=86400'
response.headers[b'Vary'] = b'Accept-Language'
Expand Down

0 comments on commit ee6f42e

Please sign in to comment.