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

feat: upgrade packages, refactor report command #238

Merged
merged 10 commits into from
Feb 5, 2024
Prev Previous commit
Next Next commit
fix: fix DSN regex to handle port numbers
  • Loading branch information
vishnu-deepsource committed Feb 2, 2024
commit 76a5069447775d03970b65a6f5cb5c5def3445cd
2 changes: 1 addition & 1 deletion command/report/dsn.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type DSN struct {
}

func NewDSN(raw string) (*DSN, error) {
dsnPattern := regexp.MustCompile(`^(https?)://([^:@]+)@([^:/]+)`)
var dsnPattern = regexp.MustCompile(`^(https?)://([^:@]+)@([^:/]+(?:\:\d+)?)`)
matches := dsnPattern.FindStringSubmatch(raw)
if len(matches) != 4 {
return nil, ErrInvalidDSN
Expand Down
11 changes: 11 additions & 0 deletions command/report/dsn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ func TestNewDSN(t *testing.T) {
},
wantErr: nil,
},
{
name: "valid DSN with port",
args: args{
raw: "http://f59a44307@localhost:8081",
},
want: &DSN{
Token: "f59a44307",
Host: "localhost:8081",
Protocol: "http",
},
},
{
name: "invalid DSN no http",
args: args{
Expand Down
Loading