pull/2310/head
Ayrat Badykov 5 years ago
parent d6de19938c
commit 23a23293d1
No known key found for this signature in database
GPG Key ID: B44668E265E9396F
  1. 3
      apps/block_scout_web/lib/block_scout_web/views/api_docs_view.ex
  2. 12
      apps/block_scout_web/test/block_scout_web/views/api_docs_view_test.exs

@ -37,8 +37,9 @@ defmodule BlockScoutWeb.APIDocsView do
def blockscout_url do def blockscout_url do
if System.get_env("BLOCKSCOUT_HOST") do if System.get_env("BLOCKSCOUT_HOST") do
%URI{host: host, scheme: scheme} = URI.parse(Endpoint.url()) %URI{host: host, scheme: scheme} = URI.parse(Endpoint.url())
path = System.get_env("NETWORK_PATH") || "/"
scheme <> "://" <> host scheme <> "://" <> host <> path
else else
Endpoint.url() Endpoint.url()
end end

@ -7,8 +7,18 @@ defmodule BlockScoutWeb.ApiDocsViewTest do
test "returns url with scheme and host without port" do test "returns url with scheme and host without port" do
System.put_env("BLOCKSCOUT_HOST", "localhost") System.put_env("BLOCKSCOUT_HOST", "localhost")
assert APIDocsView.blockscout_url() == "http://localhost" assert APIDocsView.blockscout_url() == "http://localhost/"
assert Endpoint.url() == "http://localhost:4002" assert Endpoint.url() == "http://localhost:4002"
end end
test "returns url with scheme and host with path" do
System.put_env("BLOCKSCOUT_HOST", "localhost/chain/dog")
System.put_env("NETWORK_PATH", "/chain/dog")
assert APIDocsView.blockscout_url() == "http://localhost/chain/dog"
assert Endpoint.url() == "http://localhost:4002"
System.put_env("NETWORK_PATH", "")
end
end end
end end

Loading…
Cancel
Save