Commit 8cda3c43 authored by Vitaly Lipatov's avatar Vitaly Lipatov

eget: fix absolute path on a site

parent 0bb6fd69
...@@ -368,12 +368,23 @@ is_url() ...@@ -368,12 +368,23 @@ is_url()
echo "$1" | grep -q "://" echo "$1" | grep -q "://"
} }
# drop file path from URL
get_host_only()
{
echo "$1/" | grep -Eo '(.*://[^/]+)'
}
# Args: URL filename # Args: URL filename
make_fileurl() make_fileurl()
{ {
local url="$1" local url="$1"
local fn="$2" local fn="$2"
fn="$(echo "$fn" | sed -e 's|^./||' -e 's|^/+||')" fn="$(echo "$fn" | sed -e 's|^./||' -e 's|^/+||')"
# if there is file path from the root of the site
if echo "$fn" | grep -q "^/" ; then
echo "$(get_host_only "$url")$fn"
return
fi
# workaround for a slash in the end of URL # workaround for a slash in the end of URL
echo "$(echo "$url" | sed -e 's|/*$||')/$fn" echo "$(echo "$url" | sed -e 's|/*$||')/$fn"
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment