diff --git a/src/canonical/handler.js b/src/canonical/handler.js index 62fc2f08..18b8f922 100644 --- a/src/canonical/handler.js +++ b/src/canonical/handler.js @@ -36,6 +36,10 @@ export const CANONICAL_CHECKS = Object.freeze({ check: 'canonical-url-status-ok', explanation: 'The canonical URL should return a 200 status code to ensure it is accessible and indexable by search engines.', }, + CANONICAL_URL_NO_REDIRECT: { + check: 'canonical-url-no-redirect', + explanation: 'The canonical URL should be a direct link without redirects to ensure search engines recognize the intended page.', + }, CANONICAL_URL_4XX: { check: 'canonical-url-4xx', explanation: 'The canonical URL returns a 4xx error, indicating it is inaccessible, which can harm SEO visibility.', @@ -44,10 +48,6 @@ export const CANONICAL_CHECKS = Object.freeze({ check: 'canonical-url-5xx', explanation: 'The canonical URL returns a 5xx server error, indicating it is temporarily or permanently unavailable, affecting SEO performance.', }, - CANONICAL_URL_NO_REDIRECT: { - check: 'canonical-url-no-redirect', - explanation: 'The canonical URL should be a direct link without redirects to ensure search engines recognize the intended page.', - }, CANONICAL_SELF_REFERENCED: { check: 'canonical-self-referenced', explanation: 'The canonical URL should point to itself to indicate that it is the preferred version of the content.', diff --git a/test/audits/canonical.test.js b/test/audits/canonical.test.js index 2782b2f8..affaeaeb 100644 --- a/test/audits/canonical.test.js +++ b/test/audits/canonical.test.js @@ -443,7 +443,7 @@ describe('Canonical URL Tests', () => { it('should handle 4xx error response correctly', async () => { const canonicalUrl = 'http://example.com/404'; - nock('http://example.com').get('/404').reply(404); // Simulate a 404 response + nock('http://example.com').get('/404').reply(404); const result = await validateCanonicalRecursively(canonicalUrl, log); @@ -457,7 +457,7 @@ describe('Canonical URL Tests', () => { it('should handle 5xx error response correctly', async () => { const canonicalUrl = 'http://example.com/500'; - nock('http://example.com').get('/500').reply(500); // Simulate a 500 response + nock('http://example.com').get('/500').reply(500); const result = await validateCanonicalRecursively(canonicalUrl, log); @@ -473,7 +473,6 @@ describe('Canonical URL Tests', () => { const href = '/canonical-page'; const expectedCanonicalUrl = 'https://example.com/canonical-page'; - // Mock the HTML content with a canonical link const html = ` @@ -485,7 +484,6 @@ describe('Canonical URL Tests', () => { `; - // Mock the fetch response to return the above HTML nock('https://example.com') .get('/some-page') .reply(200, html); @@ -508,7 +506,7 @@ describe('Canonical URL Tests', () => { it('should handle unexpected status code response correctly', async () => { const canonicalUrl = 'http://example.com/300'; - nock('http://example.com').get('/300').reply(300); // Simulate a 300 response + nock('http://example.com').get('/300').reply(300); const result = await validateCanonicalRecursively(canonicalUrl, log);