From 749b028ca9591155cdcfce5226fbb615796cc625 Mon Sep 17 00:00:00 2001
From: Kid <44045911+kidonng@users.noreply.github.com>
Date: Tue, 12 Jul 2022 20:20:55 +0800
Subject: Improve reliability of `patch-diff-links` (#5817)

---
 source/features/patch-diff-links.tsx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'source/features/patch-diff-links.tsx')

diff --git a/source/features/patch-diff-links.tsx b/source/features/patch-diff-links.tsx
index 1c434a3c..79d2ce25 100644
--- a/source/features/patch-diff-links.tsx
+++ b/source/features/patch-diff-links.tsx
@@ -3,10 +3,12 @@ import select from 'select-dom';
 import * as pageDetect from 'github-url-detection';
 
 import features from '.';
+import {getCleanPathname} from '../github-helpers';
 
 function init(): void {
-	let commitUrl = location.pathname.replace(/\/$/, '');
+	let commitUrl = '/' + getCleanPathname();
 
+	// Avoids a redirection
 	if (pageDetect.isPRCommit()) {
 		commitUrl = commitUrl.replace(/\/pull\/\d+\/commits/, '/commit');
 	}
-- 
cgit v1.2.3

