Skip to content

Commit b5a59a7

Browse files
authored
Merge pull request #214 from mschoettle/rewrite-github-urls
Replace GitHub URLs outside of the owner namespace to avoid backlink spam
2 parents 0a82136 + ec1f92e commit b5a59a7

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
@@ -1279,6 +1279,15 @@ export class GithubHelper {
12791279
milestoneReplacer(p1, '')
12801280
);
12811281

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

0 commit comments

Comments
 (0)