Skip to content

Commit

Permalink
Merge pull request #80 from ctbucha/bug-fix-absolute-local-path
Browse files Browse the repository at this point in the history
Bug fix: relative URI starting with a slash
  • Loading branch information
ityonemo authored Mar 10, 2024
2 parents 1a63956 + 6c11735 commit d89e061
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions lib/exonerate/tools.ex
Original file line number Diff line number Diff line change
Expand Up @@ -306,18 +306,27 @@ defmodule Exonerate.Tools do
base_path = path || "/"
dest_path = target.path || ""

if String.ends_with?(path, "/") do
%URI{
path: Path.join(base_path, dest_path),
query: target.query,
fragment: target.fragment
}
else
%URI{
path: Path.join(Path.dirname(base_path), dest_path),
query: target.query,
fragment: target.fragment
}
cond do
String.starts_with?(dest_path, "/") ->
%URI{
path: dest_path,
query: target.query,
fragment: target.fragment
}

String.ends_with?(path, "/") ->
%URI{
path: Path.join(base_path, dest_path),
query: target.query,
fragment: target.fragment
}

true ->
%URI{
path: Path.join(Path.dirname(base_path), dest_path),
query: target.query,
fragment: target.fragment
}
end

# target is absolute.
Expand Down

0 comments on commit d89e061

Please sign in to comment.