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

Exclude special search URLs from isRepoRoot and isRepoHome #178

Conversation

kang8
Copy link
Contributor

@kang8 kang8 commented Jul 30, 2023

Fixes #173

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.

This issue is similar in complexity to #131 because /user/repo?search=1 is technically a repo home but doesn't have the DOM we expect it to have.

Since we don't actually need a standalone isRepoTreeFileFinder, we can avoid exporting it and rename it to hasSearchParameter.

I think we need:

  • _isRepoRoot (not exported), which runs the necessary checks for the repo root, except hasSearchParameter
  • isRepoRoot = () => !hasSearchParameter() && _isRepoRoot()
  • isRepoTree = () => _isRepoRoot() || Boolean(getRepo(url)?.path.startsWith('tree/'))

This is because currently isRepoTree is first excluding isRepoTreeFileFinder inside isRepoRoot and then adding it again later. With a private _isRepoRoot we don't need this awkward dance.

index.ts Outdated Show resolved Hide resolved
index.ts Outdated Show resolved Hide resolved
index.ts Outdated Show resolved Hide resolved
index.ts Outdated Show resolved Hide resolved
index.ts Outdated Show resolved Hide resolved
@kang8 kang8 marked this pull request as draft July 31, 2023 14:45
@kang8 kang8 marked this pull request as ready for review July 31, 2023 15:02
@kang8
Copy link
Contributor Author

kang8 commented Jul 31, 2023

It's very strange that none of the commits after the first one triggered a GitHub Action.

e.g.

@fregante fregante changed the title Fix /user/repo?search=1 should not match isRepoRoot nor isRepoHome Exclude special search URLs from isRepoRoot and isRepoHome Jul 31, 2023
@fregante fregante merged commit 3c87228 into refined-github:main Jul 31, 2023
@fregante
Copy link
Member

Thanks @kang8!

@fregante
Copy link
Member

v8 has been released. Would you like to send a PR to RG to update it? There are a few changes to make, considering all the updates included:

https://github.com/refined-github/github-url-detection/releases/tag/v8.0.0

@kang8
Copy link
Contributor Author

kang8 commented Aug 1, 2023

Would you like to send a PR to RG to update it?

Yes, I will submit a PR after work.

@kang8 kang8 deleted the fix-user-repo-search-1-not-match-isreporoot-nor-isrepohome branch August 1, 2023 02:01
@kang8 kang8 restored the fix-user-repo-search-1-not-match-isreporoot-nor-isrepohome branch August 1, 2023 02:11
@kang8 kang8 deleted the fix-user-repo-search-1-not-match-isreporoot-nor-isrepohome branch August 1, 2023 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

/user/repo?search=1 should not match isRepoRoot nor isRepoHome
2 participants