@@ -66,6 +66,10 @@ module.exports = async () => {
6666 node . categories . push ( "catalogue" ) ;
6767 }
6868
69+ const stripRelativeTags = ( html ) => html
70+ . replace ( / < l i n k \b [ ^ > ] * ?\b h r e f = (?: [ " ' ] | & q u o t ; ) (? ! h t t p s ? : \/ \/ ) [ ^ " ' > & ] * (?: [ " ' ] | & q u o t ; ) [ ^ > ] * \/ ? > / gi, '' )
71+ . replace ( / < s c r i p t \b [ ^ > ] * ?\b s r c = (?: [ " ' ] | & q u o t ; ) (? ! h t t p s ? : \/ \/ ) [ ^ " ' > & ] * (?: [ " ' ] | & q u o t ; ) [ ^ > ] * > (?: [ \s \S ] * ?< \/ s c r i p t > ) ? / gi, '' ) ;
72+
6973 // Fetch full npm node details (readme, etc.)
7074 try {
7175 const nodeDetails = await EleventyFetch (
@@ -133,12 +137,30 @@ module.exports = async () => {
133137 }
134138 } ) ;
135139
140+ let sanitizedFlow = flowContent ;
141+ try {
142+ const flowJson = JSON . parse ( flowContent ) ;
143+ const sanitizeNode = ( n ) => {
144+ if ( n && typeof n === 'object' ) {
145+ if ( typeof n . template === 'string' ) n . template = stripRelativeTags ( n . template ) ;
146+ if ( typeof n . html === 'string' ) n . html = stripRelativeTags ( n . html ) ;
147+ }
148+ return n ;
149+ } ;
150+ if ( Array . isArray ( flowJson ) ) {
151+ flowJson . forEach ( sanitizeNode ) ;
152+ } else {
153+ sanitizeNode ( flowJson ) ;
154+ }
155+ sanitizedFlow = JSON . stringify ( flowJson ) ;
156+ } catch ( _ ) { /* keep original if not valid JSON */ }
157+
136158 return {
137159 name : file . name . replace ( '.json' , '' ) , // Remove .json extension for display
138160 path : file . path ,
139161 url : file . html_url ,
140162 downloadUrl : file . download_url ,
141- flow : flowContent // Store the actual flow JSON as string
163+ flow : sanitizedFlow
142164 } ;
143165 } catch ( err ) {
144166 console . error ( `Failed to fetch flow content for ${ file . name } :` , err . message ) ;
@@ -195,6 +217,7 @@ module.exports = async () => {
195217 return match ;
196218 }
197219 ) ;
220+ node . readme = stripRelativeTags ( node . readme ) ;
198221 } else {
199222 node . readme = "" ;
200223 }
0 commit comments