~sircmpwn/sr.ht-dev

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH builds.sr.ht] Avoid 404 when requesting /~<username>/

Details
Message ID
<20230627080211.16396-1-denis@laxalde.org>
DKIM signature
missing
Download raw message
Patch: +1 -1
E.g. https://builds.sr.ht/~sircmpwn/ responds with 404; this is due to
how flask deals with trailing slashes in route's definition:
https://flask.palletsprojects.com/en/2.3.x/api/#url-route-registrations

Since there are sub-routes like /~<username>/job/<id>, the user might be tempted
to navigate up by editing the URL and getting a 404 when they "forget"
to remove the trailing / is annoying.

Now with the rule ending with a /, both requesting with and without the
trailing slash would work.
---
 buildsrht/blueprints/jobs.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/buildsrht/blueprints/jobs.py b/buildsrht/blueprints/jobs.py
index d37c1a5..64d823d 100644
--- a/buildsrht/blueprints/jobs.py
@@ -283,7 +283,7 @@ def cancel(job_id):
    requests_session.post(f"http://{job.runner}/job/{job.id}/cancel")
    return redirect("/~" + current_user.username + "/job/" + str(job.id))

@jobs.route("/~<username>")
@jobs.route("/~<username>/")
def user(username):
    user = User.query.filter(User.username == username).first()
    if not user:
-- 
2.39.2
Details
Message ID
<CTNA0I2CK6YF.1ZU7NNXBW4BM@taiga>
In-Reply-To
<20230627080211.16396-1-denis@laxalde.org> (view parent)
DKIM signature
missing
Download raw message
The trailing slash issue has come up a few times, and this kind of
patchwork one-route-at-a-time solution has been rejected before. The
appropriate fix for this is to come up with a plan for dealing with
trailing slashes site-wide and apply a solution consitently to all
routes in all services at once.

[builds.sr.ht/patches] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CTNA16C1YREI.2TN0YX34P9S3J@cirno2>
In-Reply-To
<20230627080211.16396-1-denis@laxalde.org> (view parent)
DKIM signature
missing
Download raw message
builds.sr.ht/patches: FAILED in 4m13s

[Avoid 404 when requesting /~<username>/][0] from [Denis Laxalde][1]

[0]: https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/42189
[1]: denis@laxalde.org

✗ #1014382 FAILED  builds.sr.ht/patches/archlinux.yml https://builds.sr.ht/~sircmpwn/job/1014382
✓ #1014381 SUCCESS builds.sr.ht/patches/alpine.yml    https://builds.sr.ht/~sircmpwn/job/1014381
✓ #1014383 SUCCESS builds.sr.ht/patches/debian.yml    https://builds.sr.ht/~sircmpwn/job/1014383
Details
Message ID
<Z-YBvQLirsFXumb8_m5RBDCbwczidKdDexd_3-NXzdTwafhF3Fy89-PK20lYhMbOkNczX9UvfkP8DySs3fxNxO1-jt2wPf3ioKj6cWy-6bc=@emersion.fr>
In-Reply-To
<CTNA0I2CK6YF.1ZU7NNXBW4BM@taiga> (view parent)
DKIM signature
missing
Download raw message
On Tuesday, June 27th, 2023 at 10:06, Drew DeVault <sir@cmpwn.com> wrote:

> The trailing slash issue has come up a few times, and this kind of
> patchwork one-route-at-a-time solution has been rejected before. The
> appropriate fix for this is to come up with a plan for dealing with
> trailing slashes site-wide and apply a solution consitently to all
> routes in all services at once.

See e.g. https://git.sr.ht/~sircmpwn/git.sr.ht/commit/2a5f5783d60bdb476352f3087bd77ea271338822
Reply to thread Export thread (mbox)