Skip to content

Commit

Permalink
fix(C.SC.1.3,C.SI.1.4): ignore non-string contents
Browse files Browse the repository at this point in the history
  • Loading branch information
tensor5 committed Jul 30, 2024
1 parent 5b6dd80 commit 28b5771
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/audits/municipality/themeVersionCheckAudit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,15 @@ class LoadAudit extends Audit {
styleCSSUrl = await buildUrl(url, styleCSSUrl);
}

let CSScontent = "";
let CSSContent = "";
try {
const response = await axios.get(styleCSSUrl);
CSScontent = response.data;
CSSContent = typeof response.data === "string" ? response.data : "";
} catch (e) {
CSScontent = "";
CSSContent = "";
}

const match = CSScontent.match(cmsThemeRx);
const match = CSSContent.match(cmsThemeRx);

if (match === null || !match.groups) {
continue;
Expand Down
12 changes: 6 additions & 6 deletions src/audits/school/themeVersionCheckAudit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ class LoadAudit extends Audit {
const $: CheerioAPI = await loadPageData(url);
const linkTags = $("link");

let styleCSSurl = "";
let styleCSSUrl = "";
for (const linkTag of linkTags) {
if (!linkTag.attribs || !("href" in linkTag.attribs)) {
continue;
}

if (linkTag.attribs.href.includes(".css")) {
styleCSSurl = linkTag.attribs.href;
if ((await isInternalUrl(styleCSSurl)) && !styleCSSurl.includes(url)) {
styleCSSurl = await buildUrl(url, styleCSSurl);
styleCSSUrl = linkTag.attribs.href;
if ((await isInternalUrl(styleCSSUrl)) && !styleCSSUrl.includes(url)) {
styleCSSUrl = await buildUrl(url, styleCSSUrl);
}

let CSSContent = "";
try {
const response = await axios.get(styleCSSurl);
CSSContent = response.data;
const response = await axios.get(styleCSSUrl);
CSSContent = typeof response.data === "string" ? response.data : "";
} catch (e) {
CSSContent = "";
}
Expand Down

0 comments on commit 28b5771

Please sign in to comment.