diff --git a/dsn.go b/dsn.go index 5b4b109e3..947533225 100644 --- a/dsn.go +++ b/dsn.go @@ -149,6 +149,9 @@ func (dsn Dsn) StoreAPIURL() *url.URL { if dsn.port != dsn.scheme.defaultPort() { rawURL += fmt.Sprintf(":%d", dsn.port) } + if dsn.path != "" { + rawURL += dsn.path + } rawURL += fmt.Sprintf("/api/%d/store/", dsn.projectID) parsedURL, _ := url.Parse(rawURL) return parsedURL diff --git a/dsn_test.go b/dsn_test.go index e6d096e0d..b8637030a 100644 --- a/dsn_test.go +++ b/dsn_test.go @@ -84,6 +84,16 @@ func TestValidDsnNoPort(t *testing.T) { assertEqual(t, "http://domain/api/42/store/", dsn.StoreAPIURL().String()) } +func TestValidDsnPrefixed(t *testing.T) { + url := "http://username@domain/prefixed/42" + dsn, err := NewDsn(url) + + if err != nil { + t.Error("expected dsn to be correctly created") + } + assertEqual(t, "http://domain/prefixed/api/42/store/", dsn.StoreAPIURL().String()) +} + func TestValidDsnInsecureNoPort(t *testing.T) { url := "https://username@domain/42" dsn, err := NewDsn(url)