MCPcopy Create free account
hub / github.com/upper/db / ParseURL

Function ParseURL

adapter/sqlite/connection.go:81–110  ·  view source on GitHub ↗

ParseURL parses s into a ConnectionURL struct.

(s string)

Source from the content-addressed store, hash-verified

79
80// ParseURL parses s into a ConnectionURL struct.
81func ParseURL(s string) (conn ConnectionURL, err error) {
82 var u *url.URL
83
84 if !strings.HasPrefix(s, connectionScheme+"://") {
85 return conn, fmt.Errorf(`Expecting file:// connection scheme.`)
86 }
87
88 if u, err = url.Parse(s); err != nil {
89 return conn, err
90 }
91
92 conn.Database = u.Host + u.Path
93 conn.Options = map[string]string{}
94
95 var vv url.Values
96
97 if vv, err = url.ParseQuery(u.RawQuery); err != nil {
98 return conn, err
99 }
100
101 for k := range vv {
102 conn.Options[k] = vv.Get(k)
103 }
104
105 if _, ok := conn.Options["cache"]; !ok {
106 conn.Options["cache"] = "shared"
107 }
108
109 return conn, err
110}

Callers 2

LookupNameMethod · 0.70
TestParseConnectionURLFunction · 0.70

Calls 2

ErrorfMethod · 0.65
GetMethod · 0.65

Tested by 1

TestParseConnectionURLFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…