Skip to content

Commit 59e5efd

Browse files
Remove parseURL()
1 parent 2be12a0 commit 59e5efd

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

pgutils/connector.go

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ func (f connectionStringProviderFunc) ConnectionString(ctx context.Context) (str
5353
//
5454
// For postgres+rds-iam, the provider generates a fresh IAM auth token on each ConnectionString(ctx) call.
5555
func NewConnectionStringProviderFromURLString(ctx context.Context, rawURL string) (ConnectionStringProvider, error) {
56-
u, err := parseURL(rawURL)
56+
u, err := url.Parse(rawURL)
5757
if err != nil {
58-
return nil, err
58+
return nil, fmt.Errorf("parsing URL: %w", err)
5959
}
6060

6161
switch u.Scheme {
@@ -112,21 +112,10 @@ func MustConnectDB(conn driver.Connector) *sqlx.DB {
112112
return db
113113
}
114114

115-
func parseURL(rawURL string) (*url.URL, error) {
116-
if strings.TrimSpace(rawURL) == "" {
117-
return nil, errors.New("rawURL cannot be empty")
118-
}
119-
u, err := url.Parse(rawURL)
120-
if err != nil {
121-
return nil, fmt.Errorf("parsing URL: %w", err)
122-
}
123-
return u, nil
124-
}
125-
126115
// addSearchPathToURL returns a copy of u with search_path set in the query string.
127116
// It returns an error if search_path is already present.
128117
func addSearchPathToURL(rawURL string, searchPath string) (string, error) {
129-
u, err := parseURL(rawURL)
118+
u, err := url.Parse(rawURL)
130119
if err != nil {
131120
return "", fmt.Errorf("url string failed to parse while adding search path: %w", err)
132121
}

0 commit comments

Comments
 (0)