Skip to content
This repository was archived by the owner on Mar 10, 2021. It is now read-only.

Commit ad854f2

Browse files
robinheinzejamonholmgren
authored andcommitted
Normalize URL slug prior to retrieving page
1 parent 2591f98 commit ad854f2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/thesis/controller.ex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,10 @@ defmodule Thesis.Controller.Plug do
9090
end
9191

9292
def call(conn, _opts) do
93-
current_page = store.page(conn.request_path)
93+
url = conn.request_path
94+
|> String.replace(~r/(?<=[^:])(\/\/)/, conn.request_path, "/") # Strip double slashes
95+
|> String.replace(~r/\/$/, "") # Strip trailing slash
96+
current_page = store.page(url)
9497
page_contents = store.page_contents(current_page)
9598

9699
conn

0 commit comments

Comments
 (0)