File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -542,8 +542,16 @@ export interface RepositoryInfo {
542
542
543
543
const getRepo = ( url ?: URL | HTMLAnchorElement | Location | string ) : RepositoryInfo | undefined => {
544
544
if ( ! url ) {
545
- const canonical = document . querySelector < HTMLMetaElement > ( '[property="og:url"]' ) ; // `rel=canonical` doesn't appear on every page
546
- url = canonical ? canonical . content : location ;
545
+ // We use `canonical` here to use the correct capitalization
546
+ // `rel=canonical` doesn't appear on every page
547
+ const canonical = document . querySelector < HTMLMetaElement > ( '[property="og:url"]' ) ;
548
+ if ( canonical ) {
549
+ const canonicalUrl = new URL ( canonical . content , location . origin ) ;
550
+ // Sometimes GitHub sets the canonical to an incomplete URL, so it can't be used
551
+ if ( getCleanPathname ( canonicalUrl ) . toLowerCase ( ) === getCleanPathname ( location ) . toLowerCase ( ) ) {
552
+ url = canonicalUrl ;
553
+ }
554
+ }
547
555
}
548
556
549
557
if ( typeof url === 'string' ) {
You can’t perform that action at this time.
0 commit comments