fix(billing): replace text/template with strings.Replace in checkout URL templating#1619
fix(billing): replace text/template with strings.Replace in checkout URL templating#1619rohilsurana wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesURL templating simplification
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 2✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
billing/checkout/service.go (1)
488-493: ⚡ Quick winConsider using
strings.ReplaceAllfor better readability.The implementation correctly replaces the checkout ID placeholder. For improved code clarity, consider using
strings.ReplaceAll(available since Go 1.12) instead ofstrings.Replacewith-1:✨ Proposed refactor
func (s *Service) templatizeUrls(ch Checkout, checkoutID string) Checkout { - ch.SuccessUrl = strings.Replace(ch.SuccessUrl, "{{.CheckoutID}}", checkoutID, -1) - ch.CancelUrl = strings.Replace(ch.CancelUrl, "{{.CheckoutID}}", checkoutID, -1) + ch.SuccessUrl = strings.ReplaceAll(ch.SuccessUrl, "{{.CheckoutID}}", checkoutID) + ch.CancelUrl = strings.ReplaceAll(ch.CancelUrl, "{{.CheckoutID}}", checkoutID) return ch }
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 958b8017-818d-4798-9243-affca3811f58
📒 Files selected for processing (1)
billing/checkout/service.go
Coverage Report for CI Build 25918869693Coverage increased (+0.03%) to 42.339%Details
Uncovered Changes
Coverage Regressions2 previously-covered lines in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
Summary
templatizeUrlsused Go'stext/templateto process user-suppliedSuccessUrlandCancelUrl, which supports arbitrary function calls and complex expressions beyond simple variable interpolationstrings.Replacesince the only placeholder is{{.CheckoutID}}text/templateandbytesimports, addsstringsTest plan
go buildandgo vetpass{{.CheckoutID}}correctly in success/cancel URLs