diff options
author | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-01-01 22:34:04 +0100 |
---|---|---|
committer | Hiltjo Posthuma <hiltjo@codemadness.org> | 2021-01-01 22:59:09 +0100 |
commit | 7e4c07313301fdc43bd60f328dba8bf638813a37 (patch) | |
tree | b0e04e97fd9e5e5f14997775cf6018c1564ed2d9 | |
parent | cfcdae2a394a2ac0d180ff34cae17e30422d0800 (diff) |
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.
-rwxr-xr-x | sfeed_update | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sfeed_update b/sfeed_update index 398c408..0d39625 100755 --- a/sfeed_update +++ b/sfeed_update @@ -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}" |