finish /u redirect from 9fff6ae9 with 301s

This commit is contained in:
Peter Bhat Harkins 2024-01-02 10:45:00 -06:00
parent ac3b88c72a
commit 4fd296e508
2 changed files with 7 additions and 16 deletions

View File

@ -146,14 +146,14 @@ Rails.application.routes.draw do
:as => "user_enable_invite"
# 2023-07 redirect /u to /~username and /users (for tree)
get "/u", to: redirect("/users", status: 302)
get "/u/:username", to: redirect("/~%{username}", status: 302)
get "/u", to: redirect("/users", status: 301)
get "/u/:username", to: redirect("/~%{username}", status: 301)
# we don't do /@alice but easy mistake with comments autolinking @alice
get "/@:username", to: redirect("/~%{username}", status: 302)
get "/u/:username/standing", to: redirect("~%{username}/standing", status: 302)
get "/newest/:user", to: redirect("~%{user}/stories", status: 302)
get "/newest/:user(/page/:page)", to: redirect("~%{user}/stories/page/%{page}", status: 302)
get "/threads/:user", to: redirect("~%{user}/threads", status: 302)
get "/@:username", to: redirect("/~%{username}", status: 301)
get "/u/:username/standing", to: redirect("~%{username}/standing", status: 301)
get "/newest/:user", to: redirect("~%{user}/stories", status: 301)
get "/newest/:user(/page/:page)", to: redirect("~%{user}/stories/page/%{page}", status: 301)
get "/threads/:user", to: redirect("~%{user}/threads", status: 301)
get "/avatars/:username_size.png" => "avatars#show"
post "/avatars/expire" => "avatars#expire"

View File

@ -54,13 +54,4 @@ describe "user redirects", type: :request do
it "threads" do
expect(get("/threads/alice")).to redirect_to("/~alice/threads")
end
# 2023-07: I'm deploying with 302 redirects so I don't have to worry about 301s getting
# indefinitely cached in case of error, but after some time to build confidence, it's appropriate
# to 301. I'm putting a time bomb test in here to remind me to finalize.
it "is temporarily temporary" do
expect(get("/u/alice")).to eq(302)
expect(Time.zone.today).to be_before(Date.new(2024, 1, 1))
end
end