Skip to content

Commit ec1f92e

Browse files
committed
Replace GitHub URLs outside of the owner namespace to avoid backlink spam
1 parent 7cae049 commit ec1f92e

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/githubHelper.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,15 @@ export class GithubHelper {
12751275
milestoneReplacer(p1, '')
12761276
);
12771277

1278+
// Replace github.com URLs to other organizations with redirect.github.com to avoid backlink spam
1279+
let urlMassager = (str: string) => {
1280+
return 'redirect.github.com';
1281+
}
1282+
1283+
// Keep owner internal links/back links intact
1284+
reString = `((?:to|redirect\\.|www\\.)?github\\.com)(?!\\/${settings.github.owner}\\/)`;
1285+
str = str.replace(new RegExp(reString, 'g'), (_, p1) => urlMassager(p1));
1286+
12781287
//
12791288
// Label reference conversion
12801289
//

0 commit comments

Comments
 (0)