Skip to content

Commit

Permalink
Update validate.sh (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
barkermn01 authored Nov 30, 2024
1 parent 45a136c commit d92a758
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions .github/workflows/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ for file in mods/**/*.xml; do
ret=1
fi

# Check Mod.LatestVersion.Link
# Check Mod.LatestVersion.Link
latest_version_link=$(xmllint --xpath 'string(//Mod/LatestVersion/Link)' "$file")

# Parse the iros:// URI format
if [[ $latest_version_link =~ ^iroj://([a-zA-Z]+)/ ]]; then
protocol=${BASH_REMATCH[1]}
uri_path=${latest_version_link#iros://$protocol/}
uri_path=${latest_version_link#iroj://$protocol/}

case ${protocol,,} in # ${protocol,,} converts to lowercase
"url")
latest_version_link=${uri_path/\$/:\/\/}
latest_version_link="https://${uri_path}"
;;
"gdrive")
latest_version_link="https://drive.google.com/file/d/${uri_path}"
Expand All @@ -45,12 +46,9 @@ for file in mods/**/*.xml; do
;;
esac
fi
# Now check the converted URL
curl --output /dev/null --silent --head --fail "$latest_version_link" -A "Mozilla/5.0"
if [ $? -ne 0 ]; then
errors+=" - Verify LatestVersion.Link failed: [link]($latest_version_link)\n"
ret=1
fi

# For debugging
echo "Original: $latest_version_link"

# Check Mod.LatestVersion.PreviewImage
preview_image=$(xmllint --xpath 'string(//Mod/LatestVersion/PreviewImage)' "$file")
Expand Down

0 comments on commit d92a758

Please sign in to comment.