s3rius / rustus

TUS protocol implementation in Rust.
https://s3rius.github.io/rustus/
MIT License
158 stars 13 forks source link

Extra path separator when using `RUSTUS_URL=/` #85

Closed Kaelten closed 2 years ago

Kaelten commented 2 years ago

When I use '/' for the path instead of /files things work, but the path that is generated for the files contain an extra /. Here's a log snippet that shows the issue.

rustus  | [2022-06-22][01:03:13+00:00][INFO] "POST / HTTP/1.1" "-" "201" "172.19.0.1" "66.578333"
rustus  | [2022-06-22][01:03:14+00:00][INFO] "PATCH //10ac0e0e-d67d-4e2c-880b-1346793008b5 HTTP/1.1" "-" "204" "172.19.0.1" "263.382625"

In these situations I've found that using a url join library often is the cleanest way to eliminate duplications and ensure urls are built properly. Failing that doing a regex replace so that /+ is replaced with / works fairly well as well.

s3rius commented 2 years ago

Hi, and thanks for pointing this out. I fixed URLs normalization. It was a problem caused by the logic I used for dynamic route creation.

Kaelten commented 2 years ago

Looks great here. Thanks again! :)