Skip to content

Commit

Permalink
fix: handle lists in redirects properly, add corresponding test
Browse files Browse the repository at this point in the history
  • Loading branch information
zachdaniel committed Sep 17, 2024
1 parent 000c028 commit a5dc896
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/ex_doc/formatter/html.ex
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ defmodule ExDoc.Formatter.HTML do

def generate_redirects(config, ext) do
config.redirects
|> Map.new()
|> Map.put_new("index", config.main)
|> Enum.map(fn {from, to} ->
unless is_binary(from),
Expand Down
24 changes: 24 additions & 0 deletions test/ex_doc/formatter/html_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,30 @@ defmodule ExDoc.Formatter.HTMLTest do
</html>
"""
end

test "redirects accept a list", %{tmp_dir: tmp_dir} = context do
generate_docs(
doc_config(context,
extras: ["test/fixtures/LICENSE"],
redirects: [
{"/old-license", "license"}
]
)
)

assert File.read!(tmp_dir <> "/html/old-license.html") == """
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Elixir v1.0.1 — Documentation</title>
<meta http-equiv="refresh" content="0; url=license.html">
<meta name="generator" content="ExDoc v0.34.2">
</head>
<body></body>
</html>
"""
end
end

describe "generates extras" do
Expand Down

0 comments on commit a5dc896

Please sign in to comment.