fix: strip .git suffix from normalized repository url#2116
fix: strip .git suffix from normalized repository url#2116yeyuqwer wants to merge 1 commit intonpmx-dev:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📝 WalkthroughWalkthroughThis pull request modifies the git provider utilities by extending the Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 1✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment Tip CodeRabbit can enforce grammar and style rules using `languagetool`.Configure the |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 23d98de5-5e99-481a-8626-a88618deb915
📒 Files selected for processing (2)
shared/utils/git-providers.tstest/unit/shared/utils/git-providers.spec.ts
| if (!raw) return null | ||
|
|
||
| const normalized = raw.replace(/^git\+/, '') | ||
| const normalized = raw.replace(/^git\+/, '').replace(/\.git\/?$/, '') |
There was a problem hiding this comment.
Handle uppercase .GIT suffixes consistently.
The new suffix strip is case-sensitive, so values like .../repo.GIT remain unnormalised and can still break downstream repository links.
Diff
- const normalized = raw.replace(/^git\+/, '').replace(/\.git\/?$/, '')
+ const normalized = raw.replace(/^git\+/, '').replace(/\.git\/?$/i, '')📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const normalized = raw.replace(/^git\+/, '').replace(/\.git\/?$/, '') | |
| const normalized = raw.replace(/^git\+/, '').replace(/\.git\/?$/i, '') |
|
There's another open PR that fixes this #2111 |
🔗 Linked issue
#2114
🧭 Context
normalizeGitUrldoes not strip the.gitsuffix from repository URLs. WhenuseRepositoryUrlappends/tree/HEAD/<directory>for monorepo packages, the resulting URL contains.gitin the path (e.g.https://github.com/facebook/react.git/tree/HEAD/packages/react), which leads to a 404 on GitHub.📚 Description
Strip the
.gitsuffix innormalizeGitUrl()during URL normalization, so downstream consumers likeuseRepositoryUrlproduce clean, valid URLs.The fix adds
.replace(/\.git\/?$/, '')to the normalization chain inshared/utils/git-providers.ts. This is safe because each git provider'sparsePathalready had its own.replace(/\.git$/i, '')on the repo name — those now become no-ops.Before:
https://github.com/facebook/react.git/tree/HEAD/packages/react(404)After:
https://github.com/facebook/react/tree/HEAD/packages/react(valid)All existing unit tests in
git-providers.spec.tscontinue to pass.