Current section
37 Versions
Jump to
Current section
37 Versions
Compare versions
9
files changed
+26
additions
-10
deletions
| @@ -42,7 +42,7 @@ _If you are having problems, view `README_INSTALL.md` for manual instructions._ | |
| 42 42 | |
| 43 43 | ```elixir |
| 44 44 | def deps do |
| 45 | - [{:thesis, "~> 0.0.27"}] |
| 45 | + [{:thesis, "~> 0.0.28"}] |
| 46 46 | end |
| 47 47 | |
| 48 48 | def application do |
| @@ -6,7 +6,7 @@ For automatic setup, see `README.md`. | |
| 6 6 | |
| 7 7 | ```elixir |
| 8 8 | def deps do |
| 9 | - [{:thesis, "~> 0.0.27"}] |
| 9 | + [{:thesis, "~> 0.0.28"}] |
| 10 10 | end |
| 11 11 | |
| 12 12 | def application do |
| @@ -138,8 +138,8 @@ | |
| 138 138 | <<"README_INSTALL.md">>,<<"LICENSE.md">>,<<"package.json">>]}. |
| 139 139 | {<<"licenses">>,[<<"MIT">>]}. |
| 140 140 | {<<"links">>, |
| 141 | - [{<<"Docs">>,<<"https://hexdocs.pm/thesis/0.0.27/api-reference.html">>}, |
| 142 | - {<<"GitHub">>,<<"https://github.com/infinitered/thesis">>}]}. |
| 141 | + [{<<"Docs">>,<<"https://hexdocs.pm/thesis/0.0.28/api-reference.html">>}, |
| 142 | + {<<"GitHub">>,<<"https://github.com/infinitered/thesis-phoenix">>}]}. |
| 143 143 | {<<"maintainers">>, |
| 144 144 | [<<"Jamon Holmgren">>,<<"Yulian Glukhenko">>,<<"Ken Miller">>, |
| 145 145 | <<"Daniel Berkompas">>]}. |
| @@ -169,4 +169,4 @@ | |
| 169 169 | {<<"name">>,<<"html_sanitize_ex">>}, |
| 170 170 | {<<"optional">>,false}, |
| 171 171 | {<<"requirement">>,<<">= 1.0.1">>}]]}. |
| 172 | - {<<"version">>,<<"0.0.27">>}. |
| 172 | + {<<"version">>,<<"0.0.28">>}. |
| @@ -90,7 +90,8 @@ defmodule Thesis.Controller.Plug do | |
| 90 90 | end |
| 91 91 | |
| 92 92 | def call(conn, _opts) do |
| 93 | - current_page = store.page(conn.request_path) |
| 93 | + url = Thesis.Utilities.normalize_url(conn.request_path) |
| 94 | + current_page = store.page(url) |
| 94 95 | page_contents = store.page_contents(current_page) |
| 95 96 | |
| 96 97 | conn |
| @@ -3,6 +3,7 @@ defmodule Thesis.Utilities do | |
| 3 3 | Module that provides helper functions. |
| 4 4 | """ |
| 5 5 | |
| 6 | + |
| 6 7 | def parameterize(str) do |
| 7 8 | str = Regex.replace(~r/[^a-z0-9\-\s\.]/i, str, "") |
| 8 9 | Regex.split(~r/\%20|\s/, str) |
| @@ -18,4 +19,18 @@ defmodule Thesis.Utilities do | |
| 18 19 | |> String.downcase |
| 19 20 | |> binary_part(0, length) |
| 20 21 | end |
| 22 | + |
| 23 | + @doc """ |
| 24 | + Takes a URL and strips unnecessary characters. |
| 25 | + |
| 26 | + iex> Thesis.Utilities.normalize_url("http://infinite.red//ignite//foo") |
| 27 | + "http://infinite.red/ignite/foo" |
| 28 | + iex> Thesis.Utilities.normalize_url("https://infinite.red/ignite/foo/") |
| 29 | + "https://infinite.red/ignite/foo" |
| 30 | + """ |
| 31 | + def normalize_url(url) do |
| 32 | + url |
| 33 | + |> String.replace(~r/(?<=[^:])(\/\/)/, "/") # Strip double slashes |
| 34 | + |> String.replace(~r/\/$/, "") # Strip trailing slash |
| 35 | + end |
| 21 36 | end |
Loading more files…