Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore support for https://github.com exception #64

Merged
merged 2 commits into from
Nov 8, 2024

Conversation

kovsu
Copy link
Member

@kovsu kovsu commented Oct 30, 2024

@kovsu
Copy link
Member Author

kovsu commented Oct 30, 2024

As you can see if url is https://github.com, shortenRepoUrl function runs to end. Because these properties is empty, so it returns an empty string and makes the link is swallowed.

shorten-repo-url/index.js

Lines 274 to 276 in ce4fcc4

// Drop leading and trailing slash of relative path
return pathname.replaceAll(/^[/]|[/]$/g, '') + url.search + hash + query;

@kovsu
Copy link
Member Author

kovsu commented Oct 30, 2024

If we get the pathname is /, it goes to here.

shorten-repo-url/index.js

Lines 159 to 178 in ce4fcc4

if (isReserved || pathname === '/' || (!isLocal && !isRaw && !isRedirection)) {
const cleanHref = [
origin
.replace(/^https:[/][/]/, '')
.replace(/^www[.]/, ''),
pathname
.replace(/[/]$/, ''),
];
if (['issues', 'pulls'].includes(user) && !repo) {
const query = pullQueryOut(url.searchParams, url.pathname);
cleanHref.push(url.search, query);
} else {
cleanHref.push(url.search);
}
cleanHref.push(decodeURI(url.hash));
return cleanHref.join('');
}

so we will get a cleanHref that is github.com

@kovsu
Copy link
Member Author

kovsu commented Oct 30, 2024

@fregante Please review ~

Copy link
Member

@fregante fregante left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation! I broke this in b1232be (#61)

Can you add a test? Make sure it fails without this change

@fregante fregante changed the title Fix pathname is empty Restore support for https://github.com exception Oct 30, 2024
@fregante fregante added the bug label Oct 30, 2024
@kovsu
Copy link
Member Author

kovsu commented Oct 31, 2024

image

@kovsu
Copy link
Member Author

kovsu commented Nov 8, 2024

@fregante Should I merge this? I think you forget this.

@fregante
Copy link
Member

fregante commented Nov 8, 2024

I thought I commented 😅 yes you can.

Also a new patch version can be released

@kovsu kovsu merged commit 306f4dd into refined-github:main Nov 8, 2024
3 checks passed
@kovsu kovsu deleted the fix-1 branch November 8, 2024 01:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants