File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -188,10 +188,16 @@ ${textContent}
188188 // Perform GitHub URL conversion here to differentiate between user-provided
189189 // URL and the actual URL to be fetched.
190190 const urls = extractUrls ( params . prompt ) . map ( ( url ) => {
191- if ( url . includes ( 'github.com' ) && url . includes ( '/blob/' ) ) {
192- return url
193- . replace ( 'github.com' , 'raw.githubusercontent.com' )
194- . replace ( '/blob/' , '/' ) ;
191+ try {
192+ const parsedUrl = new URL ( url ) ;
193+ if ( parsedUrl . hostname === 'github.com' && url . includes ( '/blob/' ) ) {
194+ return url
195+ . replace ( 'github.com' , 'raw.githubusercontent.com' )
196+ . replace ( '/blob/' , '/' ) ;
197+ }
198+ } catch ( e ) {
199+ // If URL parsing fails, ignore this URL
200+ console . error ( `Invalid URL encountered: ${ url } ` ) ;
195201 }
196202 return url ;
197203 } ) ;
You can’t perform that action at this time.
0 commit comments