Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for slash in group name #36

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/fun_with_flags/ui/templates.ex
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ defmodule FunWithFlags.UI.Templates do
def url_safe(val) do
val
|> to_string()
|> URI.encode()
|> URI.encode(fn (c) -> c != ?/ and URI.char_unescaped?(c) end)
end
end
12 changes: 11 additions & 1 deletion test/fun_with_flags/ui/templates_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ defmodule FunWithFlags.UI.TemplatesTest do
end


describe "url_safe" do
test "it escapes / character" do
assert Templates.url_safe("/") == "%2F"
end

test "it escapes { character" do
assert Templates.url_safe("{") == "%7B"
end
end

describe "_head()" do
test "it renders", %{conn: conn} do
out = Templates._head(conn: conn, title: "Coconut")
Expand Down Expand Up @@ -153,7 +163,7 @@ defmodule FunWithFlags.UI.TemplatesTest do
out = Templates.details(conn: conn, flag: flag)

assert String.contains?(out, ~s{<div id="actor_moss:&lt;h1&gt;123&lt;/h1&gt;"})
assert String.contains?(out, ~s{<form action="/pear/flags/avocado/actors/moss:%3Ch1%3E123%3C/h1%3E" method="post"})
assert String.contains?(out, ~s{<form action="/pear/flags/avocado/actors/moss:%3Ch1%3E123%3C%2Fh1%3E" method="post"})

assert String.contains?(out, ~s{<div id="group_rocks"})
assert String.contains?(out, ~s{<form action="/pear/flags/avocado/groups/rocks" method="post"})
Expand Down