handle edges cases when redirecting

master
Aevann 2023-09-20 16:54:34 +03:00
parent 4adb2e5d23
commit b49b2d0381
2 changed files with 3 additions and 3 deletions

View File

@ -1086,7 +1086,7 @@ def u_username_wall_comment(v, username, cid):
def u_username(v, username):
u = get_user(username, v=v, include_blocks=True)
if username != u.username:
return redirect(SITE_FULL + request.full_path.replace(username, u.username))
return redirect(SITE_FULL + request.full_path.replace(f'/@{username}/posts', f'/@{u.username}/posts'))
if v and hasattr(u, 'is_blocking') and u.is_blocking:
if g.is_api_or_xhr:

View File

@ -7,12 +7,12 @@
{% block content %}
<ul class="nav post-nav py-2">
<li class="nav-item">
<a class="nav-link {% if request.path.endswith('/posts') %}active" href="{{request.path}}"{% else %}" href="{{request.path.replace('comments','posts')}}"{% endif %}>
<a class="nav-link {% if request.path.endswith('/posts') %}active" href="{{request.path}}"{% else %}" href="{{request.path.replace('/comments','/posts')}}"{% endif %}>
Posts
</a>
</li>
<li class="nav-item">
<a class="nav-link {% if request.path.endswith('/comments') %}active" href="{{request.path}}"{% else %}" href="{{request.path.replace('posts','comments')}}"{% endif %}>
<a class="nav-link {% if request.path.endswith('/comments') %}active" href="{{request.path}}"{% else %}" href="{{request.path.replace('/posts','/comments')}}"{% endif %}>
Comments
</a>
</li>