Skip to content

Commit

Permalink
Merge pull request #3640 from SwiftPackageIndex/canonical-debug-panel
Browse files Browse the repository at this point in the history
Cope with pages that have no canonical in the JS debug panel
  • Loading branch information
daveverwer authored Jan 28, 2025
2 parents 7d645ea + 3dfc88b commit 5ccd4b2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions FrontEnd/scripts/debug_panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ export class SPIDebugPanel extends HTMLElement {
}

addCanonicalUrls() {
const canonicalUrl = document.querySelector('link[rel="canonical"]').href
const canonicalUrl = document.querySelector('link[rel="canonical"]')?.href
const windowUrl = window.location.href
const matchingCanonicalUrl = canonicalUrl === windowUrl

this.newTableRow('Canonical URL', canonicalUrl)
this.newTableRow('Canonical URL', canonicalUrl ? canonicalUrl : 'Missing', canonicalUrl ? null : 'red')
this.newTableRow('Window URL', windowUrl)
this.newTableRow('Canonical Match', matchingCanonicalUrl, matchingCanonicalUrl ? 'green' : 'red')
}
Expand Down

0 comments on commit 5ccd4b2

Please sign in to comment.