From 7a84ef31175842e9811d29e58990ee9303e4c349 Mon Sep 17 00:00:00 2001 From: The_miro Date: Wed, 5 Aug 2026 23:12:40 +0200 Subject: [PATCH] Handle a mirror served under a base path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deriving the site URL by reducing the mirror URL to its origin discarded any base path, so a mirror at https://host/abdelpakDelta/mods produced a pack URL of https://host/packs/ — a location nothing serves. Strip the last path segment instead, which gives the right answer with or without a base path. The server address derivation also only stripped scheme and port, so a site URL carrying a path leaked it into the address shown to players. Strip the path too. Co-Authored-By: Claude Opus 5 --- packwiz-setup.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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%/}"