   defp path(from, segments),
     do: Path.join([from|segments])
 
+  # if not a subset, returns nil instead of []
   defp subset([h|expected], [h|actual]),
     do: subset(expected, actual)
   defp subset([], actual),
     do: actual
   defp subset(_, _),
-    do: []
+    do: nil
 
   defp invalid_path?([h|_]) when h in [".", "..", ""], do: true
   defp invalid_path?([h|t]), do: String.contains?(h, ["/", "\\", ":"]) or invalid_path?(t)

    end
  end

  defp allowed?(_only, _prefix, []), do: false
  defp allowed?([], [], _list), do: true
  defp allowed?(only, prefix, [h|_]) do
    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
    basepath = Path.join("/", Path.join(Path.join(at), Path.join(segments)))
    conn
    |> put_resp_header("content-type", "text/html")

    end
  end

  defp directory_file_info(path) do
    case :prim_file.read_file_info(path) do
      {:ok, file_info(type: :directory) = file_info} ->
