Skip to content

Commit 306f4dd

Browse files
authored
Restore support for https://github.com` exception (#64)
1 parent fc0f933 commit 306f4dd

File tree

3 files changed

+4
-1
lines changed

3 files changed

+4
-1
lines changed

__snapshots__/index.test.js.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ exports[`https://example.com/nodejs/node/blob/cc8fc46/.gitignore 1`] = `example.
1616

1717
exports[`https://example.site/한글로-된-URL 1`] = `example.site/한글로-된-URL`;
1818

19+
exports[`https://github.com 1`] = `github.com`;
20+
1921
exports[`https://github.com/ 1`] = `github.com`;
2022

2123
exports[`https://github.com/bfred-it/shorten-repo-url/network/dependencies 1`] = `bfred-it/shorten-repo-url (dependencies)`;

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function shortenRepoUrl(href, currentUrl = 'https://github.com') {
8484
* Parse URL manually to avoid URL encoding and punycode
8585
*/
8686
const origin = href.split('/', 3).join('/');
87-
const pathname = href.slice(origin.length).replace(/[?#].*/, '');
87+
const pathname = href.slice(origin.length).replace(/[?#].*/, '') || '/';
8888
const hash = /#.+$/.exec(href)?.[0] ?? '';
8989

9090
// Use URL exclusively for search parameters because they're too hard to parse

index.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ const urls = [
118118
'https://github.com/trending/developers',
119119
'https://github.com/settings/profile',
120120
'https://github.com/',
121+
'https://github.com',
121122
'https://github.com/fregante/shorten-repo-url/issues',
122123
'https://github.com/fregante/shorten-repo-url/issues?q=wow',
123124
'https://github.com/fregante/shorten-repo-url/issues?q=is%3Aissue++is%3Aopen+sort%3Aupdated-desc+&unrelated=true',

0 commit comments

Comments
 (0)