Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pr-notification-link
- New feature (#7104)
- Loading branch information
Showing
5 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as pageDetect from 'github-url-detection'; | ||
|
||
import features from '../feature-manager.js'; | ||
import observe from '../helpers/selector-observer.js'; | ||
|
||
const regex = /\/files\/[\da-f]{40}..[\da-f]{40}$/; | ||
|
||
function trimLink(link: HTMLAnchorElement): void { | ||
if (regex.test(link.pathname)) { | ||
link.pathname = link.pathname.replace(regex, ''); | ||
link.hash = '#issue-comment-box'; | ||
} | ||
} | ||
|
||
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*=".."]', trimLink, {signal}); | ||
} | ||
|
||
void features.add(import.meta.url, { | ||
include: [ | ||
pageDetect.isNotifications, | ||
], | ||
init, | ||
}); | ||
|
||
/* | ||
Test URL: | ||
https://github.com/notifications | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters