new_audit(canonical): document has a valid rel=canonical#4163
new_audit(canonical): document has a valid rel=canonical#4163paulirish merged 14 commits intoGoogleChrome:masterfrom
Conversation
…th the same name).
| if (HEADER_SAFELIST.has(headerName.toLowerCase())) { | ||
| headers[headerName] = headerValue; | ||
| headers[headerName] = headers[headerName] || []; | ||
| headers[headerName].push(headerValue); |
There was a problem hiding this comment.
Some headers can appear multiple times in the HTTP response (set-cookie, link, etc.) and, in such cases, {name:[value1, value2]} is a format expected by response.writeHead.
| canonicalURL.pathname === '/' && baseURL.pathname !== '/') { | ||
| return { | ||
| rawValue: false, | ||
| displayValue: 'points to a root of the same origin', |
There was a problem hiding this comment.
@rviscomi I made these displayValues very short and while this works for invalid URL all others require more explanation. Not sure if displayValue is the right place for this explanation though (limited formatting, not much space) - maybe separate documentation page that we discussed would help here?
There was a problem hiding this comment.
Can the failureDescription be overwritten to have failure-specific explanations?
There was a problem hiding this comment.
Is the immutability of failureDescription a bug or a feature? cc @paulirish
| failureDescription: 'Links do not have descriptive text', | ||
| helpText: 'Descriptive link text helps search engines understand your content. ' + | ||
| '[Learn more](https://webmasters.googleblog.com/2008/10/importance-of-link-architecture.html)', | ||
| '[Learn more](https://webmasters.googleblog.com/2008/10/importance-of-link-architecture.html).', |
| @@ -0,0 +1,166 @@ | |||
| /** | |||
| * @license Copyright 2017 Google Inc. All Rights Reserved. | |||
There was a problem hiding this comment.
@paulirish you always check those 😉 so here is a fun riddle - I created this file in 2017, but it will be merged into master in 2018. Should I put 2017 or 2018 here?
| canonicalURL.pathname === '/' && baseURL.pathname !== '/') { | ||
| return { | ||
| rawValue: false, | ||
| displayValue: 'points to a root of the same origin', |
There was a problem hiding this comment.
Can the failureDescription be overwritten to have failure-specific explanations?
| failureDescription: 'Links do not have descriptive text', | ||
| helpText: 'Descriptive link text helps search engines understand your content. ' + | ||
| '[Learn more](https://webmasters.googleblog.com/2008/10/importance-of-link-architecture.html)', | ||
| '[Learn more](https://webmasters.googleblog.com/2008/10/importance-of-link-architecture.html).', |
| @@ -0,0 +1,166 @@ | |||
| /** | |||
| * @license Copyright 2017 Google Inc. All Rights Reserved. | |||
|
|
||
| if (canonicals.length === 0) { | ||
| return { | ||
| rawValue: true, |
There was a problem hiding this comment.
when 4052 lands, we'll want to add notApplicable: true to this case.
There was a problem hiding this comment.
I added it right away (it doesn't really matter if this PR will be merge after or before #4052)
|
@patrickhulce we talked with @rviscomi about your idea to split this audit into two (errors with weight 1 and warnings with weight 0). On the one hand, it'd allow us to have separate titles and descriptions for both audits and provide more explanation, but on the other hand, it would create a confusing situation where user gets 100/100 but still sees that one of the audits is failing. So, if you don't have any strong feelings regarding the split we'd like to avoid it. |
patrickhulce
left a comment
There was a problem hiding this comment.
this looks a-ok to me! 👌
there's probably a nicer looking way we can handle the displayValue issue in the future but doesn't make sense to block on it 👍
over to @paulirish for any closing thoughts
| }; | ||
| } | ||
|
|
||
| // another common mistake is to have canonical pointing from all pages of the website to its root |
There was a problem hiding this comment.
still somewhat 😢 that this can fail for intentional usage. though I don't have a real life example so it's probably fine :)
|
|
||
| it('fails when canonical points to the root while current URL is not the root', () => { | ||
| const mainResource = { | ||
| url: 'https://example.com/articles/cats-and-you', |
| baseURL.href !== canonicalURL.href) { | ||
| return { | ||
| rawValue: false, | ||
| displayValue: `points to another hreflang location (${baseURL.href})`, |
There was a problem hiding this comment.
Rather than overloading displayValue I think we should abuse debugString like we already do for the PWA ones.
We can even extend https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/audits/multi-check-audit.js much like the splash screen one.
This also sorts out the mutable failureDescription concern above.
(yes, debugString is supposed to be exceptions, not details of failing tests. But since the PWA audits are already violating that, we might as well violate it here, too.)
There was a problem hiding this comment.
TIL about the multi-check-audit! Looks cool, but it probably makes most sense for audits returning multiple failures (Failures: ${result.failures.join(', ')}.) and this one doesn't, so I'll just switch displayValues to debugStrings.
|
@paulirish thank you for taking a look at this! I addressed your debugString comment: |



Closes #3178
Success:

Failure:
