Skip to content

Commit

Permalink
feat: log every check
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreiAlexandruParaschiv committed Aug 2, 2024
1 parent 58807c1 commit 786a6b0
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/canonical/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,21 @@ const ChecksAndErrors = Object.freeze({
error: 'canonical-url-not-in-sitemap',
explanation: 'The canonical URL should be included in the sitemap to facilitate its discovery by search engines, improving indexing.',
},
CANONICAL_URL_4XX: {
check: 'canonical-url-4xx',
error: 'canonical-url-4xx-error',
explanation: 'The canonical URL returns a 4xx error, indicating it is inaccessible, which can harm SEO visibility.',
CANONICAL_URL_200: {
check: 'canonical-url-200',
error: 'canonical-url-not-200',
explanation: 'The canonical URL should return a 200 status code to ensure it is accessible and indexable by search engines.',
},
CANONICAL_URL_3XX: {
check: 'canonical-url-3xx',
error: 'canonical-url-3xx-redirect',
explanation: 'The canonical URL returns a 3xx redirect, which may lead to confusion for search engines and dilute page authority.',
},
CANONICAL_URL_4XX: {
check: 'canonical-url-4xx',
error: 'canonical-url-4xx-error',
explanation: 'The canonical URL returns a 4xx error, indicating it is inaccessible, which can harm SEO visibility.',
},
CANONICAL_URL_5XX: {
check: 'canonical-url-5xx',
error: 'canonical-url-5xx-error',
Expand Down Expand Up @@ -414,7 +419,7 @@ async function validateCanonicalUrlContentsRecursive(canonicalUrl, log, visitedU
if (response.ok) { // 2xx status codes
log.info(`Canonical URL is valid and accessible: ${canonicalUrl}`);
checks.push({
check: ChecksAndErrors.CANONICAL_TAG_EXISTS.check,
check: ChecksAndErrors.CANONICAL_URL_200.check,
success: true,
});

Expand Down Expand Up @@ -548,7 +553,7 @@ export async function canonicalAuditRunner(input, context) {

const urlContentCheck = await validateCanonicalUrlContentsRecursive(canonicalUrl, log);
log.info(`validateCanonicalUrlContentsRecursive result for ${canonicalUrl}: ${JSON.stringify(urlContentCheck)}`);
checks.push(urlContentCheck);
checks.push(...urlContentCheck);
}
log.info(`Checks for URL ${url}: ${JSON.stringify(checks)}`);
return { [url]: checks };
Expand Down

0 comments on commit 786a6b0

Please sign in to comment.