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 2dcf57a commit e285f67
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/canonical/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ async function validateCanonicalUrlContentsRecursive(canonicalUrl, log, visitedU
*
* @param {string} canonicalUrl - The canonical URL to validate.
* @param {string} baseUrl - The base URL to compare against.
* @param log
* @returns {Array<Object>} Array of check results, each with a check and error if the check failed.
*/

Expand All @@ -343,13 +344,13 @@ function validateCanonicalUrlFormat(canonicalUrl, baseUrl, log) {
check: ChecksAndErrors.CANONICAL_URL_ABSOLUTE.check,
error: ChecksAndErrors.CANONICAL_URL_ABSOLUTE.error,
});
log.info(`Canonical URL ${canonicalUrl} is not absolute.`);
log.info(`Canonical URL is not absolute: ${canonicalUrl}`);
} else {
checks.push({
check: ChecksAndErrors.CANONICAL_URL_ABSOLUTE.check,
success: true,
});
log.info(`Canonical URL ${canonicalUrl} is absolute.`);
log.info(`Canonical URL is absolute: ${canonicalUrl}`);
}

// Check if the canonical URL has the same protocol as the base URL
Expand All @@ -358,13 +359,13 @@ function validateCanonicalUrlFormat(canonicalUrl, baseUrl, log) {
check: ChecksAndErrors.CANONICAL_URL_SAME_PROTOCOL.check,
error: ChecksAndErrors.CANONICAL_URL_SAME_PROTOCOL.error,
});
log.info(`Canonical URL ${canonicalUrl} uses a different protocol.`);
log.info(`Canonical URL does not have the same protocol as base URL: ${canonicalUrl}`);
} else {
checks.push({
check: ChecksAndErrors.CANONICAL_URL_SAME_PROTOCOL.check,
success: true,
});
log.info(`Canonical URL ${canonicalUrl} uses the same protocol.`);
log.info(`Canonical URL has the same protocol as base URL: ${canonicalUrl}`);
}

// Check if the canonical URL has the same domain as the base URL
Expand All @@ -373,13 +374,13 @@ function validateCanonicalUrlFormat(canonicalUrl, baseUrl, log) {
check: ChecksAndErrors.CANONICAL_URL_SAME_DOMAIN.check,
error: ChecksAndErrors.CANONICAL_URL_SAME_DOMAIN.error,
});
log.info(`Canonical URL ${canonicalUrl} is not on the same domain.`);
log.info(`Canonical URL does not have the same domain as base URL: ${canonicalUrl}`);
} else {
checks.push({
check: ChecksAndErrors.CANONICAL_URL_SAME_DOMAIN.check,
success: true,
});
log.info(`Canonical URL ${canonicalUrl} is on the same domain.`);
log.info(`Canonical URL has the same domain as base URL: ${canonicalUrl}`);
}

// Check if the canonical URL is in lowercase
Expand All @@ -388,13 +389,13 @@ function validateCanonicalUrlFormat(canonicalUrl, baseUrl, log) {
check: ChecksAndErrors.CANONICAL_URL_LOWERCASED.check,
error: ChecksAndErrors.CANONICAL_URL_LOWERCASED.error,
});
log.info(`Canonical URL ${canonicalUrl} is not lowercased.`);
log.info(`Canonical URL is not in lowercase: ${canonicalUrl}`);
} else {
checks.push({
check: ChecksAndErrors.CANONICAL_URL_LOWERCASED.check,
success: true,
});
log.info(`Canonical URL ${canonicalUrl} is lowercased.`);
log.info(`Canonical URL is in lowercase: ${canonicalUrl}`);
}

return checks;
Expand Down

0 comments on commit e285f67

Please sign in to comment.