💾 Archived View for lists.flounder.online › patches › threads › 20210320000714.11299-2-johann@qwertq… captured on 2022-04-28 at 19:24:43. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

[PATCH mygit 2/4] recognize repositories with trailing slash

[PATCH mygit 2/4] recognize repositories with trailing slash

From: johann@qwertqwefsday.eu

Date: Sat, 20 Mar 2021 01:07:12 +0100

Message-Id: 20210320000714.11299-2-johann@qwertqwefsday.eu

To: <~aw/patches@lists.sr.ht>

In-Reply-To: 20210320000714.11299-1-johann@qwertqwefsday.eu

Cc: "Johann150" <johann@qwertqwefsday.eu>

Reply

Export

--------------------------------------

From: Johann150 <johann@qwertqwefsday.eu>

---

src/main.rs | 1 +

1 file changed, 1 insertion(+)

diff --git a/src/main.rs b/src/main.rs

index 33d1afe..fe97363 100644

--- a/src/main.rs

+++ b/src/main.rs

@@ -473,6 +473,7 @@ async fn main() -> Result<(), std::io::Error> {

.serve_file("templates/static/style.css")?; // TODO configurable

app.at("/:repo_name").get(repo_home);

// ALSO do git pull at this url somehow ^

+ app.at("/:repo_name/").get(repo_home);

app.at("/:repo_name/commit/:commit").get(repo_commit);

app.at("/:repo_name/refs").get(repo_refs);

app.at("/:repo_name/log").get(repo_log);

--

2.20.1

Re: [PATCH mygit 2/4] recognize repositories with trailing slash

From: alex@alexwennerberg.com

Date: Sat, 20 Mar 2021 10:45:14 -0700

Message-Id: CA2D694KI6AS.1M2TTCKUJA2LS@debian-alex

To: "Johann Galle" <johann@qwertqwefsday.eu>, <~aw/patches@lists.sr.ht>

In-Reply-To: 20210320000714.11299-2-johann@qwertqwefsday.eu

Reply

Export

--------------------------------------

This is an OK workaround for now, but I think there is tide middleware

that will handle this for all routes

On Fri Mar 19, 2021 at 5:07 PM PDT, Johann Galle wrote:

From: Johann150 <johann@qwertqwefsday.eu>
---
src/main.rs | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/main.rs b/src/main.rs
index 33d1afe..fe97363 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -473,6 +473,7 @@ async fn main() -> Result<(), std::io::Error> {
.serve_file("templates/static/style.css")?; // TODO configurable
app.at("/:repo_name").get(repo_home);
// ALSO do git pull at this url somehow ^
+ app.at("/:repo_name/").get(repo_home);
app.at("/:repo_name/commit/:commit").get(repo_commit);
app.at("/:repo_name/refs").get(repo_refs);
app.at("/:repo_name/log").get(repo_log);
--
2.20.1

Re: [PATCH mygit 2/4] recognize repositories with trailing slash

From: johann@qwertqwefsday.eu

Date: Sat, 20 Mar 2021 21:44:24 +0100

Message-Id: 9b9f303e-1b1b-6d99-b530-95461fafeda7@qwertqwefsday.eu

To: "alex wennerberg" <alex@alexwennerberg.com>, <~aw/patches@lists.sr.ht>

In-Reply-To: CA2D694KI6AS.1M2TTCKUJA2LS@debian-alex

Reply

Export

--------------------------------------

On 20.03.2021 18:45, alex wennerberg wrote:

This is an OK workaround for now, but I think there is tide middleware
that will handle this for all routes

I think we have to be careful because browsers will behave differently for URLs ending in slash or not. E.g. if I were at "example.org/page", then a relative link "otherpage" would go to "example.org/otherpage", but on "example.org/page/" it would instead go to "example.org/page/otherpage" which might be an error.

To avoid this we would have to make sure that every link we make is an absolute link. Maybe this is already the case and I did not notice.

Re: [PATCH mygit 2/4] recognize repositories with trailing slash

From: alex@alexwennerberg.com

Date: Sat, 20 Mar 2021 20:31:25 -0700

Message-Id: CA2PN2HZLSII.CLOLZIYV30IE@debian-alex

To: "Johann Galle" <johann@qwertqwefsday.eu>, <~aw/patches@lists.sr.ht>

In-Reply-To: 9b9f303e-1b1b-6d99-b530-95461fafeda7@qwertqwefsday.eu

Reply

Export

--------------------------------------

On Sat Mar 20, 2021 at 1:44 PM PDT, Johann Galle wrote:

On 20.03.2021 18:45, alex wennerberg wrote:
> This is an OK workaround for now, but I think there is tide middleware
> that will handle this for all routes
I think we have to be careful because browsers will behave differently
for URLs ending in slash or not. E.g. if I were at "example.org/page",
then a relative link "otherpage" would go to "example.org/otherpage",
but on "example.org/page/" it would instead go to
"example.org/page/otherpage" which might be an error.
To avoid this we would have to make sure that every link we make is an
absolute link. Maybe this is already the case and I did not notice.

I think the best way to handle this is via redirects: redirect slash to

no slash. This is what I've done on other web apps