Skip to content

Commit

Permalink
Configuration.basepath helper
Browse files Browse the repository at this point in the history
  • Loading branch information
essenciary committed May 8, 2023
1 parent 57b2bb0 commit 7c4f601
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Configuration.jl
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,23 @@ buildpath()::String = Base.Filesystem.mktempdir(prefix="jl_genie_build_")
Returns the base path for the app. Optionally takes a prefix argument -- defaults to `/`.
"""
function basepath(; prefix = "/")
function basepath(; prefix = "/", ignore_empty = true)
# if base_path is not set (it's empty) then don't do anything (return empty string)
if ignore_empty && isempty(Genie.config.base_path)
return ""
end

# if base_path starts with "/" but the prefix is different, then remove the "/" from base_path
if prefix != "/" && startswith(Genie.config.base_path, "/")
return joinpath(prefix, Genie.config.base_path[2:end])
end

if prefix == "/" && ! startswith(Genie.config.base_path, "/")
return joinpath(prefix, Genie.config.base_path)
# if base_path already starts with the prefix, then return it as it is
if startswith(Genie.config.base_path, prefix)
return Genie.config.base_path
end

# otherwise, join the prefix with the base_path
return joinpath(prefix, Genie.config.base_path)
end

Expand Down

2 comments on commit 7c4f601

@essenciary
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/83101

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v5.18.0 -m "<description of version>" 7c4f60199f4bb4b3b9117a93aa3828dec375aaab
git push origin v5.18.0

Please sign in to comment.