Skip to content

Commit

Permalink
Restore support for https://github.com` exception (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
kovsu authored Nov 8, 2024
1 parent fc0f933 commit 306f4dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions __snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ exports[`https://example.com/nodejs/node/blob/cc8fc46/.gitignore 1`] = `example.

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

exports[`https://github.com 1`] = `github.com`;

exports[`https://github.com/ 1`] = `github.com`;

exports[`https://github.com/bfred-it/shorten-repo-url/network/dependencies 1`] = `bfred-it/shorten-repo-url (dependencies)`;
Expand Down
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function shortenRepoUrl(href, currentUrl = 'https://github.com') {
* Parse URL manually to avoid URL encoding and punycode
*/
const origin = href.split('/', 3).join('/');
const pathname = href.slice(origin.length).replace(/[?#].*/, '');
const pathname = href.slice(origin.length).replace(/[?#].*/, '') || '/';
const hash = /#.+$/.exec(href)?.[0] ?? '';

// Use URL exclusively for search parameters because they're too hard to parse
Expand Down
1 change: 1 addition & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const urls = [
'https://github.com/trending/developers',
'https://github.com/settings/profile',
'https://github.com/',
'https://github.com',
'https://github.com/fregante/shorten-repo-url/issues',
'https://github.com/fregante/shorten-repo-url/issues?q=wow',
'https://github.com/fregante/shorten-repo-url/issues?q=is%3Aissue++is%3Aopen+sort%3Aupdated-desc+&unrelated=true',
Expand Down

0 comments on commit 306f4dd

Please sign in to comment.