Skip to content

Commit

Permalink
Decode URLs on return
Browse files Browse the repository at this point in the history
  • Loading branch information
fregante committed Aug 26, 2024
1 parent e3e19a1 commit ecf35c8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,8 @@ function shortenRepoUrl(href, currentUrl = 'https://github.com') {

cleanHref.push(parsedUrl.hash);

return cleanHref.join('');
// The user prefers seeing the URL as it was typed, so we need to decode it
return decodeURI(cleanHref.join(''));
}

if (user && !repo) {
Expand Down
4 changes: 4 additions & 0 deletions index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ test('GitHub.com URLs', urlMatcherMacro, new Map([
'https://github.com/fregante/shorten-repo-url/wiki/%22Can-you-add-this-feature%3F%22',
'Wiki: "Can you add this feature?"',
],
[
'https://example.site/한글로-된-URL',
'example.site/한글로-된-URL',
],
]));

test('External URLs', urlMatcherMacro, new Map([
Expand Down

0 comments on commit ecf35c8

Please sign in to comment.