File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change 11//[llms-txt-valid]
22return fetch ( '/llms.txt' )
33 . then ( response => {
4- if ( ! response . ok ) return { "exists" :0 , "valid" : 0 } ;
4+ if ( ! response . ok ) return JSON . stringify ( { valid :0 , error : "Non OK status code" } ) ;
55 const ct = response . headers . get ( 'Content-Type' ) || '' ;
6- if ( ! ct . toLowerCase ( ) . includes ( 'text/plain' ) ) return { "exists" : 1 , "valid" : 0 } ;
6+ if ( ! ct . toLowerCase ( ) . includes ( 'text/plain' ) ) return JSON . stringify ( { valid : 0 , error : "Invalid content type" } ) ;
77 return response . text ( ) . then ( text => {
88 const m = s => ( text . match ( new RegExp ( `\\${ s } ` , 'g' ) ) || [ ] ) . length ;
9- if ( ( text . match ( / ` ` ` / g) || [ ] ) . length % 2 ) return { "exists" : 1 , "valid" : 0 } ;
10- if ( m ( '[' ) !== m ( ']' ) || m ( '(' ) !== m ( ')' ) ) return { "exists" : 1 , "valid" : 0 } ;
11- return { "exists" : 1 , " valid" :1 } ;
9+ if ( ( text . match ( / ` ` ` / g) || [ ] ) . length % 2 ) return JSON . stringify ( { valid : 0 , error : "" } ) ;
10+ if ( m ( '[' ) !== m ( ']' ) || m ( '(' ) !== m ( ')' ) ) return JSON . stringify ( { valid : 0 , error : "" } ) ;
11+ return JSON . stringify ( { valid ":1 } ) ;
1212 } ) ;
1313 } )
1414 . catch ( error => {
15- return JSON . stringify ( { message : error . message , error : error } ) ;
15+ return JSON . stringify ( { valid : 0 , message : error . message , error : error } ) ;
1616 } ) ;
You can’t perform that action at this time.
0 commit comments