Skip to content

Commit

Permalink
Save a 404 (ride a 302)
Browse files Browse the repository at this point in the history
  • Loading branch information
jerodsanto committed Apr 2, 2024
1 parent 22b0183 commit 6ec399e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/changelog_web/plugs/redirects.ex
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ defmodule ChangelogWeb.Plug.Redirects do
@external %{
"/sentry" => "https://sentry.io/from/changelog/",
"/square" => "https://developer.squareup.com/",
"/tailscale" => "https://tailscale.com/?utm_source=sponsorship&utm_medium=podcast&utm_campaign=changelog&utm_term=changelog",
"/tailscale" =>
"https://tailscale.com/?utm_source=sponsorship&utm_medium=podcast&utm_campaign=changelog&utm_term=changelog",
"/reactpodcast" => "https://reactpodcast.simplecast.com",
"/store" => "https://merch.changelog.com"
}

@internal %{
"/rss" => "/feed",
"/podcast/rss" => "/podcast/feed",
"/feed.js" => "/feed",
"/reactpodcast/feed" => "/jsparty/feed",
"/team" => "/about",
"/changeloggers" => "/about",
"/membership" => "/++",
Expand Down Expand Up @@ -57,7 +60,6 @@ defmodule ChangelogWeb.Plug.Redirects do

defp internal_redirect(conn = %{halted: true}), do: conn


defp internal_redirect(conn = %{request_path: path}) do
if destination = Map.get(@internal, path, false) do
conn |> Redirect.call(to: destination) |> Plug.Conn.halt()
Expand Down
1 change: 1 addition & 0 deletions lib/changelog_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ defmodule ChangelogWeb.Router do

pipeline :feed do
plug :accepts, ["xml"]
plug Plug.Redirects
plug Plug.CacheControl
end

Expand Down

0 comments on commit 6ec399e

Please sign in to comment.