-
Notifications
You must be signed in to change notification settings - Fork 211
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 specifying asset host for local storage #185
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,10 +16,10 @@ defmodule Arc.Storage.Local do | |
def url(definition, version, file_and_scope, _options \\ []) do | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's an optimization issue here, local_path = build_local_path(definition, version, file_and_scope)
host = host()
if host == "" do
Path.join "/", local_path
else
Path.join [host, local_path]
end |
||
local_path = build_local_path(definition, version, file_and_scope) | ||
|
||
if String.starts_with?(local_path, "/") do | ||
local_path | ||
if host() == "" do | ||
Path.join "/", local_path | ||
else | ||
"/" <> local_path | ||
Path.join [host(), "/", local_path] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line breaks my tests as it creates URLs like Should be |
||
end | ||
end | ||
|
||
|
@@ -34,4 +34,13 @@ defmodule Arc.Storage.Local do | |
Arc.Definition.Versioning.resolve_file_name(definition, version, file_and_scope) | ||
]) | ||
end | ||
|
||
defp host do | ||
host_url = Application.get_env(:arc, :asset_host, "") | ||
|
||
case host_url do | ||
{:system, env_var} when is_binary(env_var) -> System.get_env(env_var) | ||
url -> url | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comma in example
{:system, "ASSET_HOST"}