diff --git a/packwiz-setup.sh b/packwiz-setup.sh index c87b12b..5428532 100755 --- a/packwiz-setup.sh +++ b/packwiz-setup.sh @@ -104,12 +104,18 @@ BASEURL="${BASEURL%/}" # Everything the guides need is derivable from the mirror URL, so one -u is # usually enough; each piece can still be overridden individually. -[ -n "$SITE_URL" ] || [ -z "$BASEURL" ] || SITE_URL="$(awk -F/ '{print $1"//"$3}' <<<"$BASEURL")" +# Strip the last segment off the mirror URL rather than reducing to the origin, +# so a mirror under a base path keeps it: +# https://host/mods -> https://host +# https://host/abdelpakDelta/mods -> https://host/abdelpakDelta +[ -n "$SITE_URL" ] || [ -z "$BASEURL" ] || SITE_URL="${BASEURL%/*}" SITE_URL="${SITE_URL%/}" if [ -n "$SITE_URL" ]; then [ -n "$PACK_URL" ] || PACK_URL="$SITE_URL/packs/$slug" - [ -n "$SERVER_ADDR" ] || SERVER_ADDR="$(sed -e 's#^[a-z]*://##' -e 's#:.*##' <<<"$SITE_URL")" + # Host only: strip scheme, then any path, then any port. Dropping the path + # matters once SITE_URL can carry one. + [ -n "$SERVER_ADDR" ] || SERVER_ADDR="$(sed -e 's#^[a-z]*://##' -e 's#/.*##' -e 's#:.*##' <<<"$SITE_URL")" fi PACK_URL="${PACK_URL%/}"