Compare commits

...

2 commits

Author SHA1 Message Date
ada8122f60 chequear sources y otros elementos correctamente
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
2023-03-31 21:12:30 -03:00
558d1e66b7 add track as media 2023-03-31 20:53:21 -03:00

View file

@ -58,11 +58,65 @@ function recurseElement(page: Page, el: Element) {
});
}
}
if (["audio", "video", "img", "source", "iframe"].includes(el.name)) {
if (["audio", "video"].includes(el.name)) {
const sources = getSources(el);
for (const source of sources) {
if (source.attribs.src) {
checkUrl(page, source, source.attribs.src);
} else {
report.things.push({
type: "media-no-src",
description: getHtml(rawHtml, source),
});
}
}
}
if (["picture"].includes(el.name)) {
const sources = getSources(el);
for (const source of sources) {
if (source.attribs.srcset) {
// TODO: implementar srcset #3
} else {
report.things.push({
type: "media-no-src",
description: getHtml(rawHtml, source),
});
}
}
}
if (["img"].includes(el.name)) {
if (el.attribs.srcset) {
// TODO: implementar srcset #3
}
}
if (["audio", "video"].includes(el.name)) {
const sources = getSources(el);
if (sources.length > 0) {
for (const source of sources) {
if (source.attribs.src) {
checkUrl(page, source, source.attribs.src);
} else {
report.things.push({
type: "media-no-src",
description: getHtml(rawHtml, source),
});
}
}
} else {
if (el.attribs.src) {
checkUrl(page, el, el.attribs.src);
} else {
report.things.push({
type: "media-no-src",
description: getHtml(rawHtml, el),
});
}
}
}
if (["img", "iframe", "track"].includes(el.name)) {
if (el.attribs.src) {
checkUrl(page, el, el.attribs.src);
} else if (el.attribs.srcset) {
// TODO: implementar srcset #3
} else {
report.things.push({
type: "media-no-src",
@ -78,6 +132,12 @@ function recurseElement(page: Page, el: Element) {
}
}
function getSources(el: Element) {
return el.children.filter(
(c) => c.type === "tag" && c.name === "source"
) as Element[];
}
function checkUrl({ report, rawHtml }: Page, el: Element, url: string) {
if (isHttp(url)) {
report.things.push({