Skip to content

Commit

Permalink
Limit shorten-links to only Markdown links (#5962)
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Sep 12, 2022
1 parent e7b7951 commit 5bbdaef
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions source/features/shorten-links.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
import onetime from 'onetime';
import * as pageDetect from 'github-url-detection';

import features from '.';
import {linkifiedURLClass, shortenLink} from '../github-helpers/dom-formatters';
import observe from '../helpers/selector-observer';

/* This feature is currently so broad that it's not de-inited via signal, it's just run once for all pageloads #5889 */
function init(): void {
observe(`a[href]:not(.${linkifiedURLClass})`, shortenLink);
observe(`.comment-body a[href]:not(.${linkifiedURLClass})`, shortenLink);
}

void features.add(import.meta.url, {
exclude: [
// Due to GitHub’s bug: #2828
pageDetect.isGlobalSearchResults,
],
init: onetime(init),
});

/*
## Test URLs
https://github.com/refined-github/sandbox/pull/14
https://github.com/refined-github/refined-github/pull/473
*/

0 comments on commit 5bbdaef

Please sign in to comment.