@@ -9,7 +9,6 @@ log_verbose() {
99 [[ " $VERBOSE " == " 1" ]] && echo " Info: $* "
1010}
1111
12-
1312ASSET_EXTENSIONS_REGEX=' png|jpg|jpeg|svg|gif|webp|avif|ico|xml|yaml|yml|json|css|js|pdf|zip|tar.gz|woff|woff2|ttf|eot|mp4|webm'
1413SCRIPT_DIR=" $( cd " $( dirname " ${BASH_SOURCE[0]} " ) " && pwd) " || exit 1
1514REPO_ROOT=" $( cd " $SCRIPT_DIR /.." && pwd) " || exit 1
@@ -104,7 +103,9 @@ check_internal_link() {
104103 return 0
105104 fi
106105
107- local clean_lower=" ${clean_link,,} "
106+ # Bash 3.2 compatible lowercase conversion
107+ local clean_lower
108+ clean_lower=" $( printf " %s" " $clean_link " | tr ' [:upper:]' ' [:lower:]' ) "
108109
109110 if [[ " $clean_lower " == http://* || " $clean_lower " == https://* || " $clean_lower " == " //" * ]]; then
110111 log_verbose " Skipping external link: $link ($file :$line_no )"
@@ -119,17 +120,29 @@ check_internal_link() {
119120
120121 if [[ " $clean_link " == /docs/* ]]; then
121122 target_path=" $CONTENT_ROOT /en${clean_link} "
123+
122124 elif [[ " $clean_link " == /cn/docs/* ]]; then
123125 target_path=" $CONTENT_ROOT ${clean_link} "
126+
127+ elif [[ " $clean_link " == /community/* ]]; then
128+ target_path=" $CONTENT_ROOT /en${clean_link} "
129+
130+ elif [[ " $clean_link " == /blog/* ]]; then
131+ target_path=" $CONTENT_ROOT /en${clean_link} "
132+
133+ elif [[ " $clean_link " == /language/* ]]; then
134+ target_path=" $CONTENT_ROOT /en${clean_link} "
135+
136+ elif [[ " $clean_link " == /clients/* ]]; then
137+ target_path=" $REPO_ROOT /static${clean_link} "
138+
124139 elif [[ " $clean_link " == /* ]]; then
125- # Skip validation for ambiguous absolute paths (Hugo runtime URLs)
126- location=" $file "
127- [[ -n " $line_no " ]] && location=" $file :$line_no "
128- echo " Warning: Skipping validation for ambiguous absolute path"
129- echo " File: $location "
140+ echo " Error: Unknown absolute path"
141+ echo " File: $file :$line_no "
130142 echo " Link: $link "
131- echo " Reason: Hugo runtime URL (not directly mappable to filesystem)"
132- return 0
143+ EXIT_CODE=1
144+ return
145+
133146 else
134147 local file_dir
135148 file_dir=" $( cd " $( dirname " $file " ) " && pwd) "
@@ -141,6 +154,7 @@ check_internal_link() {
141154
142155 case " $target_path " in
143156 " $CONTENT_ROOT " /* ) ;;
157+ " $REPO_ROOT /static" /* ) ;;
144158 * )
145159 location=" $file "
146160 [[ -n " $line_no " ]] && location=" $file :$line_no "
@@ -184,31 +198,31 @@ check_internal_link() {
184198echo " Starting link validation..."
185199
186200while read -r FILE; do
187- declare -A CODE_LINES
201+ CODE_LINES= " "
188202 in_fence=false
189203 line_no=0
190204
191205 while IFS= read -r line; do
192206 (( line_no++ ))
193207
194208 if [[ " $line " =~ ^[[:space:]]* (\`\`\` | ~~~) ]]; then
195- # NOTE:
196- # Code fence detection assumes fences are properly paired.
197- # If a Markdown file contains an unclosed or mismatched fence,
198- # subsequent content may be treated as code and skipped.
199- # This script does not attempt full Markdown validation.
209+ # NOTE:
210+ # Code fence detection assumes fences are properly paired.
211+ # If a Markdown file contains an unclosed or mismatched fence,
212+ # subsequent content may be treated as code and skipped.
213+ # This script does not attempt full Markdown validation.
200214
201215 if $in_fence ; then
202216 in_fence=false
203217 else
204218 in_fence=true
205219 fi
206- CODE_LINES[ $ line_no]=1
220+ CODE_LINES= " $CODE_LINES $ line_no "
207221 continue
208222 fi
209223
210224 if $in_fence ; then
211- CODE_LINES[ $ line_no]=1
225+ CODE_LINES= " $CODE_LINES $ line_no "
212226 continue
213227 fi
214228
@@ -221,7 +235,7 @@ while read -r FILE; do
221235 escaped_line=" ${line// \\\` / } "
222236 inline_count=$( grep -o " \` " <<< " $escaped_line" | wc -l)
223237 if (( inline_count % 2 == 1 )) ; then
224- CODE_LINES[ $ line_no]=1
238+ CODE_LINES= " $CODE_LINES $ line_no "
225239 fi
226240
227241 done < " $FILE "
@@ -232,7 +246,7 @@ while read -r FILE; do
232246 LINE_NO=" ${MATCH%%:* } "
233247 LINK_PART=" ${MATCH#*: } "
234248
235- [[ ${ CODE_LINES[ $LINE_NO]} ]] && continue
249+ [[ " $ CODE_LINES" == * " $LINE_NO " * ]] && continue
236250
237251 LINK=" ${LINK_PART#* ](} "
238252 LINK=" ${LINK% )} "
0 commit comments