0 Votes

Changes for page Incidents list

Last modified by Ryan C on 2025/07/14 15:42

From version 7.1
edited by Ryan C
on 2025/07/14 14:15
Change comment: There is no comment for this version
To version 8.1
edited by Ryan C
on 2025/07/14 14:20
Change comment: There is no comment for this version

Summary

Details

Page properties
Content
... ... @@ -19,13 +19,17 @@
19 19   def headline = (rawHeadline instanceof String) ? rawHeadline.trim() : null
20 20  
21 21   def rawUrl = obj.getProperty('URL')?.value
22 - def urlValue = (rawUrl instanceof String) ? rawUrl.trim() : null
22 + def urlRaw = (rawUrl instanceof String) ? rawUrl.trim() : null
23 23  
24 - def isValidUrl = (urlValue ==~ /(?i)^https?:\/\/.+/)
24 + // Smart extraction: handles [[URL]], [[label>>URL]], raw text
25 + def urlMatch = (urlRaw =~ /(?i)(https?:\/\/[^\]\s>]+)/)
26 + def extractedUrl = urlMatch ? urlMatch[0][1] : null
27 +
28 + def isValidUrl = (extractedUrl != null)
25 25   def label = (headline && headline.length() > 0) ? headline : (fallbackTitle ?: docName)
26 26  
27 27   if (isValidUrl) {
28 - println "* [[${label}>>${urlValue}]]"
32 + println "* [[${label}>>${extractedUrl}]]"
29 29   } else {
30 30   println "* [[${label}>>doc:${docName}]]"
31 31   }

XWiki AI Chat