diff --git a/config/routes.rb b/config/routes.rb index b318ae0e..34d8fee0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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" diff --git a/spec/routing/user_spec.rb b/spec/routing/user_spec.rb index 13083e8d..ab4d0b28 100644 --- a/spec/routing/user_spec.rb +++ b/spec/routing/user_spec.rb @@ -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