Skip to content

Commit 5ccd4b2

Browse files
authored
Merge pull request #3640 from SwiftPackageIndex/canonical-debug-panel
Cope with pages that have no canonical in the JS debug panel
2 parents 7d645ea + 3dfc88b commit 5ccd4b2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

FrontEnd/scripts/debug_panel.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ export class SPIDebugPanel extends HTMLElement {
7676
}
7777

7878
addCanonicalUrls() {
79-
const canonicalUrl = document.querySelector('link[rel="canonical"]').href
79+
const canonicalUrl = document.querySelector('link[rel="canonical"]')?.href
8080
const windowUrl = window.location.href
8181
const matchingCanonicalUrl = canonicalUrl === windowUrl
8282

83-
this.newTableRow('Canonical URL', canonicalUrl)
83+
this.newTableRow('Canonical URL', canonicalUrl ? canonicalUrl : 'Missing', canonicalUrl ? null : 'red')
8484
this.newTableRow('Window URL', windowUrl)
8585
this.newTableRow('Canonical Match', matchingCanonicalUrl, matchingCanonicalUrl ? 'green' : 'red')
8686
}

0 commit comments

Comments
 (0)