Skip to content

Commit

Permalink
chore(Plugs.CanonicalHostname): remove mTicket exception (#2367)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecristen authored Feb 5, 2025
1 parent c438bb8 commit a519f6e
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 18 deletions.
10 changes: 0 additions & 10 deletions lib/dotcom_web/plugs/canonical_hostname.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@ defmodule DotcomWeb.Plugs.CanonicalHostname do
@moduledoc """
Plug to ensure that the site is only accessed via the canonical hostname.
In particular, this will prevent users going to www.mbtace.com.
There is an exception for the hostname that the mTicket app uses, since
we detect that elsewhere in the code to produce some mTicket-specific
effects when the site is loaded in mTicket's webview.
"""

@mticket_hostname "mticket.mbtace.com"

import Plug.Conn
import Phoenix.Controller, only: [redirect: 2]

def init(_) do
end

def call(%Plug.Conn{host: @mticket_hostname} = conn, _) do
conn
end

def call(%Plug.Conn{host: requested_hostname} = conn, _) do
canonical_hostname = System.get_env("HOST") || "localhost"

Expand Down
8 changes: 0 additions & 8 deletions test/dotcom_web/plugs/canonical_hostname_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@ defmodule DotcomWeb.Plugs.CanonicalHostnameTest do
alias DotcomWeb.Plugs.CanonicalHostname

describe "call/2" do
test "with the special mTicket hostname, does nothing" do
conn = %Plug.Conn{default_conn() | host: "mticket.mbtace.com"}
assert conn.status != 301

conn = CanonicalHostname.call(conn, nil)
assert conn.status != 301
end

test "with a local IP address, does nothing" do
# Class A
conn = %Plug.Conn{default_conn() | host: "10.127.127.127"}
Expand Down

0 comments on commit a519f6e

Please sign in to comment.