Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions source/features/pr-notification-link.tsx
Original file line number Diff line number Diff line change
@@ -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}$/;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth looking for "files" everywhere across the repo to check what else needs to be updated. Including test URLs

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Including test URLs

Only they can be updated, as far as I can tell after briefly checking


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, {
Expand Down
Loading