Skip to content

Commit 9e4dab2

Browse files
authored
Don't strip the hash from external URLs (#53)
1 parent c02a1a4 commit 9e4dab2

File tree

2 files changed

+33
-12
lines changed

2 files changed

+33
-12
lines changed

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ function shortenRepoUrl(href, currentUrl = 'https://github.com') {
164164
cleanHref.push(parsedUrl.search);
165165
}
166166

167+
cleanHref.push(parsedUrl.hash);
168+
167169
return cleanHref.join('');
168170
}
169171

index.test.js

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -414,18 +414,6 @@ test('GitHub.com URLs', urlMatcherMacro, new Map([
414414
'https://github.com/settings/profile',
415415
'github.com/settings/profile',
416416
],
417-
[
418-
'https://www.npmjs.com/',
419-
'npmjs.com',
420-
],
421-
[
422-
'https://www.npmjs.com/package/node',
423-
'npmjs.com/package/node',
424-
],
425-
[
426-
'https://example.com/nodejs/node/blob/cc8fc46/.gitignore',
427-
'example.com/nodejs/node/blob/cc8fc46/.gitignore',
428-
],
429417
[
430418
'https://github.com/',
431419
'github.com',
@@ -515,3 +503,34 @@ test('GitHub.com URLs', urlMatcherMacro, new Map([
515503
'Wiki: "Can you add this feature?"',
516504
],
517505
]));
506+
507+
test('External URLs', urlMatcherMacro, new Map([
508+
[
509+
'https://developer.mozilla.org/en-US/docs/Web/API/Document/createElement#parameters',
510+
'developer.mozilla.org/en-US/docs/Web/API/Document/createElement#parameters',
511+
],
512+
[
513+
'https://www.google.com/',
514+
'google.com',
515+
],
516+
[
517+
'https://wwww.google.com/',
518+
'wwww.google.com',
519+
],
520+
[
521+
'http://www.google.com/',
522+
'http://www.google.com',
523+
],
524+
[
525+
'https://www.npmjs.com/',
526+
'npmjs.com',
527+
],
528+
[
529+
'https://www.npmjs.com/package/node',
530+
'npmjs.com/package/node',
531+
],
532+
[
533+
'https://example.com/nodejs/node/blob/cc8fc46/.gitignore',
534+
'example.com/nodejs/node/blob/cc8fc46/.gitignore',
535+
],
536+
]));

0 commit comments

Comments
 (0)