Skip to content

Commit c9dd288

Browse files
authored
Return JSON
1 parent cae08e6 commit c9dd288

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

llms-txt-validation.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
//[llms-txt-valid]
22
return fetch('/llms.txt')
33
.then(response => {
4-
if (!response.ok) return 0;
4+
if (!response.ok) return {"exists":0,"valid":0};
55
const ct = response.headers.get('Content-Type')||'';
6-
if (!ct.toLowerCase().includes('text/plain')) return 0;
6+
if (!ct.toLowerCase().includes('text/plain')) return {"exists":1,"valid":0};
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 0;
10-
if (m('[')!==m(']')||m('(')!==m(')')) return 0;
11-
return 1;
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};
1212
});
1313
})
1414
.catch(error => {

0 commit comments

Comments
 (0)