sfeed_update: if baseurl is empty then use the path from the feed by default

Feeds should contain absolute urls, but if it does not have it then this makes
it more convenient to configure such feeds.
This commit is contained in:
Hiltjo Posthuma 2021-01-01 22:34:04 +01:00
parent cfcdae2a39
commit 7e4c073133
1 changed files with 7 additions and 1 deletions

View File

@ -84,11 +84,17 @@ feed() {
curjobs=$((curjobs + 1))
(name="$1"
filename="$(printf '%s' "$1" | tr '/' '_')"
feedurl="$2"
basesiteurl="$3"
encoding="$4"
# if baseurl is empty then use the path from the feed by default.
if [ "${basesiteurl}" = "" ]; then
host="${feedurl##*://}"
basesiteurl="${feedurl%%://*}://${host%/*}/"
fi
filename="$(printf '%s' "${name}" | tr '/' '_')"
sfeedfile="${sfeedpath}/${filename}"
tmpfeedfile="${sfeedtmpdir}/${filename}"