diff --git a/.gitea/workflows/test-skins.yml b/.gitea/workflows/test-skins.yml index b84265f..deff6f6 100644 --- a/.gitea/workflows/test-skins.yml +++ b/.gitea/workflows/test-skins.yml @@ -141,6 +141,7 @@ jobs: - name: Check all links in markdown files run: | #!/bin/bash + set -o pipefail echo "" echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" @@ -166,12 +167,12 @@ jobs: # Extract ALL links from the markdown file # Match both []() and direct URLs - using Perl regex for better handling - grep -oP '\]\(([^\)]+)\)' "$md_file" | sed 's/](\(.*\))/\1/' > /tmp/links_$$.txt || true + { + grep -oP '\]\(([^\)]+)\)' "$md_file" 2>/dev/null | sed 's/](\(.*\))/\1/' || true + grep -oP '!\[[^\]]*\]\(([^\)]+)\)' "$md_file" 2>/dev/null | sed 's/!\[.*\](\(.*\))/\1/' || true + } > /tmp/links_$$.txt - # Also extract image links - grep -oP '!\[[^\]]*\]\(([^\)]+)\)' "$md_file" | sed 's/!\[.*\](\(.*\))/\1/' >> /tmp/links_$$.txt || true - - link_count=$(wc -l < /tmp/links_$$.txt) + link_count=$(wc -l < /tmp/links_$$.txt 2>/dev/null || echo "0") if [ $link_count -eq 0 ]; then echo " ℹ️ No links found in this file" @@ -191,9 +192,17 @@ jobs: # Check if it's an external URL if [[ "$decoded_link" =~ ^https?:// ]]; then - # Check external URL with curl - http_code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 "$decoded_link" 2>/dev/null) - if [[ "$http_code" =~ ^2[0-9][0-9]$ ]] || [[ "$http_code" =~ ^3[0-9][0-9]$ ]]; then + # URL-encode the link for curl (convert spaces and special chars) + # Use the original encoded link, not the decoded one + encoded_url="$link" + + # Check external URL with curl (with User-Agent header for better compatibility) + http_code=$(curl -s -o /dev/null -w "%{http_code}" --max-time 10 \ + -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36" \ + "$encoded_url" 2>/dev/null || echo "000") + + # Accept 2xx and 3xx status codes as valid + if [[ "$http_code" =~ ^[23][0-9][0-9]$ ]]; then echo " ✅ $decoded_link" else echo " ❌ $decoded_link (HTTP $http_code)"