Skip to content

Commit 11976cf

Browse files
author
hhaensel
committed
fix asset_path trimming
1 parent fe72c14 commit 11976cf

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/Assets.jl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,16 @@ Generates the path to an asset file.
104104
"""
105105
function asset_path(; file::String, host::String = Genie.config.base_path, package::String = "", version::String = "",
106106
prefix::String = "assets", type::String = "$(split(file, '.')[end])", path::String = "", min::Bool = false,
107-
ext::String = "$(endswith(file, type) ? "" : ".$type")", skip_ext::Bool = false, query::String = "") :: String
108-
endswith(host, '/') || (host *= '/')
107+
ext::String = "$(endswith(file, type) ? "" : ".$type")", skip_ext::Bool = false, query::String = ""
108+
) :: String
109+
host = strip(host, '/') * '/'
109110
path = strip(path, '/')
110111
external = external_assets(host)
111-
112+
external || startswith(host, '/') || (host = "/$host")
113+
package_version = join(filter(!isempty, [package, version]), external ? '@' : '/')
112114
assetpath = string(
113115
host,
114-
join(filter(!isempty, [join([package, version], external ? '@' : '/'), prefix, type, path, file*(min ? ".min" : "")*(skip_ext ? "" : ext)]), '/'),
116+
join(filter(!isempty, [package_version, prefix, type, path, file*(min ? ".min" : "")*(skip_ext ? "" : ext)]), '/'),
115117
query
116118
)
117119
return external ? assetpath : lowercase(assetpath)

0 commit comments

Comments
 (0)