diff options
| author | grunfink <grunfink@noreply.codeberg.org> | 2026-03-20 16:19:25 +0100 |
|---|---|---|
| committer | grunfink <grunfink@noreply.codeberg.org> | 2026-03-20 16:19:25 +0100 |
| commit | 373acdc002c19afedd7d53c578c87db7769c4b7a (patch) | |
| tree | a8a9afd3cb6cba17d282daa39737b2357a566804 /httpd.c | |
| parent | 81e0683e9ce779d4f9935f8471f514cbc22e0e03 (diff) | |
| parent | 7da3f49ba23c2469a4830f8963f188744d9eea5e (diff) | |
Merge pull request 'Implemented tootfinder.ch compatibility mimic Mastodon behaviour' (#587) from rgiuse/snac2:tootfinder-patch into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/587
Diffstat (limited to 'httpd.c')
| -rw-r--r-- | httpd.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -502,6 +502,13 @@ void httpd_connection(FILE *f) if (xs_startswith(q_path, p)) q_path = xs_crop_i(q_path, strlen(p), 0); + /* add users endpoint redirection mimic Mastodon behaviour */ + const char *users_endpoint = "/users"; + if (xs_startswith(q_path, users_endpoint)) { + q_path = xs_crop_i(q_path, strlen(users_endpoint), 0); + status = HTTP_STATUS_FOUND; + } + if (strcmp(method, "GET") == 0 || strcmp(method, "HEAD") == 0) { /* cascade through */ if (status == 0) @@ -607,6 +614,9 @@ void httpd_connection(FILE *f) if (status == HTTP_STATUS_SEE_OTHER) headers = xs_dict_append(headers, "location", body); + if (status == HTTP_STATUS_FOUND) + headers = xs_dict_append(headers, "location", xs_fmt("%s%s", p, q_path)); + if (status == HTTP_STATUS_UNAUTHORIZED && body) { xs *www_auth = xs_fmt("Basic realm=\"@%s@%s snac login\"", body, xs_dict_get(srv_config, "host")); |