mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-15 05:36:17 -08:00
fix(agents): reject empty media and ignore URL at-signs
This commit is contained in:
1 parent
6558245e12
commit
a7150d1e72
3 files changed
+25
-2
No files matched your search
@@ -41,6 +41,7 @@ async function validateReference(
|
||||
if (unresolvedReference !== undefined)
|
||||
return `${source}: unresolved Markdown reference "${unresolvedReference}"`;
|
||||
if (/^(?:[a-z][a-z\d+.-]*:|\/\/)/iu.test(target)) return;
|
||||
if (image && !target) return `${source}: empty media target`;
|
||||
let path;
|
||||
let anchor;
|
||||
try {
|
||||
@@ -184,7 +185,10 @@ export async function validateAgentGuidance({ rootDir }) {
|
||||
diagnostics.push(
|
||||
`${source}: at most ${maxBytes} UTF-8 bytes allowed (received ${bytes})`
|
||||
);
|
||||
const prose = guidanceProse(markdown);
|
||||
const prose = guidanceProse(markdown).replace(
|
||||
/(?:\b[a-z][a-z\d+.-]*:\/\/|\/\/)[^\s]+/giu,
|
||||
' '
|
||||
);
|
||||
const imports = guidanceStandaloneImports(markdown);
|
||||
const inlineImports = [];
|
||||
for (const match of prose.matchAll(
|
||||
|
||||
@@ -1381,3 +1381,21 @@ for (const entity of ['	', ' ', ' ']) {
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
for (const markup of ['![logo]()', '<img src="">', '<video src=" "></video>']) {
|
||||
test(`empty media references are rejected: ${markup}`, async (t) => {
|
||||
assert.ok((await diagnostics(t, { 'AGENTS.md': markup })).length > 0);
|
||||
});
|
||||
}
|
||||
for (const url of [
|
||||
'https://example.com/@docs/guide',
|
||||
'https://example.com/user?next=@docs/guide',
|
||||
'//example.com/@docs/guide',
|
||||
]) {
|
||||
test(`external URL at-sign is not an import: ${url}`, async (t) => {
|
||||
assert.deepEqual(
|
||||
await diagnostics(t, { 'AGENTS.md': 'Visit ' + url }),
|
||||
[]
|
||||
);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user