     :erlang.list_to_binary(
       Enum.map(pathlist,
                fn(x) ->
-                 gen_ls_entry(:erlang.list_to_binary(x), subpath) end))
+                 gen_ls_entry(:erlang.list_to_binary(x)) end))
     <>
     # postamble
     """

    h in only or match?({0, _}, prefix != [] and :binary.match(h, prefix))
  end

  defp serve_directory_listing({:ok, conn, _file_info, path}, at, segments) do
    subpath = at <> "/" <> :erlang.list_to_binary(segments)
    conn
    |> put_resp_header("content-type", "text/html")
    |> send_resp(200, make_ls(path, subpath))
    |> halt
  end

  defp serve_directory_listing({:error, conn}, _at, _segments) do
    conn
  end


    """
  end

  defp gen_ls_entry(path) do
    "<li><a href=\"" <> URI.encode(path) <> "\">" <>
    Plug.HTML.html_escape(path) <> "</a></li>\n"
  end

