Conversation
The page analyzer compared `rel` and `script[type]` attribute values with `===`, so <link rel="Canonical">, <link rel="ALTERNATE" hreflang> and <script type="application/LD+JSON"> were all missed. Both attributes are ASCII case-insensitive in HTML, and the cheerio reference the parity suite compares against already matches them that way.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
analyzeHtmlcompares two HTML attribute values with===:relis an ASCII case-insensitive link-type token in HTML, and MIME types arecase-insensitive as well. htmlparser2 lowercases attribute names, not values,
so a page written as
loses its canonical, its
dehreflang, and its structured-data flag.The same file already knows this —
closeAnchorreads the very same attributeas
attribs["rel"]?.toLowerCase() ?? ""before splitting it, and the parityfixture uses
rel="NoFollow sponsored"to pin that.Downstream, a missed canonical is not just a blank column:
isDuplicateCandidatetreats a page with no canonical as eligible forduplicate grouping, so a page that is canonicalized elsewhere gets reported
under
duplicate-title/duplicate-content— the case its own comment callsout as "telling the user to fix something they already fixed". It also
suppresses
canonicalized-pageandcanonical-conflict.Fix
Lowercase both values before comparing. Nothing else changes:
rel="canonical"and
type="application/ld+json"behave exactly as before, and a multi-tokenrelis still not matched (that is the reference behaviour and out of scopehere).
Tests
The cheerio reference the parity suite compares against already matches these
case-insensitively — css-select treats
relandtypeas case-insensitiveHTML attributes — so this is a straight parity gap and one
expectParitycasecovers it, in the existing style:
The lowercase
rel="alternate"line is in there on purpose: it must keepworking, and it passes both before and after.
Against
main:With the fix:
How I tested
Windows 11, Node 22.
I did not run the whole suite or e2e.