From 8fff5d307e5be2f67b2a389266c5acc9899d1a2e Mon Sep 17 00:00:00 2001 From: Grigory Date: Thu, 14 May 2026 21:15:01 +0500 Subject: [PATCH] `pr-notification-link` - Restore feature --- source/features/pr-notification-link.tsx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/source/features/pr-notification-link.tsx b/source/features/pr-notification-link.tsx index 625b78865758..a4ebbd1d46d5 100644 --- a/source/features/pr-notification-link.tsx +++ b/source/features/pr-notification-link.tsx @@ -1,20 +1,20 @@ import * as pageDetect from 'github-url-detection'; +import {getCleanPathname} from '../github-helpers/index.js'; +import {commentBoxHashPr} from '../github-helpers/selectors.js'; import features from '../feature-manager.js'; import observe from '../helpers/selector-observer.js'; -const regex = /\/files\/[\da-f]{40}..[\da-f]{40}$/; - export function removeLinkToPrFilesTab(link: HTMLAnchorElement): void { - if (regex.test(link.pathname)) { - link.pathname = link.pathname.replace(regex, ''); - link.hash = '#issue-comment-box'; + if (pageDetect.isPRFiles(link)) { + // Owner + name + pull + number + link.pathname = getCleanPathname(link).split('/').slice(0, 4).join('/'); + link.hash = commentBoxHashPr; } } function init(signal: AbortSignal): void { - // It's ok if it's not 100% safe because trimLink's regex is super specific - observe('[href*="/pull/"][href*="/files/"][href*=".."]', removeLinkToPrFilesTab, {signal}); + observe('[href*="/pull/"][href*=".."]', removeLinkToPrFilesTab, {signal}); } void features.add(import.meta.url, {