Fixes 2: Fixing regression for issue 2
Signed-off-by: Kris Nóva <kris@nivenly.com>main
parent
414bfb6aa1
commit
afcb80f913
|
@ -23,6 +23,10 @@ const (
|
|||
// New is used to create a new Client to authenticate with
|
||||
// Photoprism.
|
||||
func New(connectionString string) *Client {
|
||||
for strings.HasSuffix(connectionString, "/") {
|
||||
connectionString = connectionString[:len(connectionString)-1]
|
||||
}
|
||||
|
||||
c := &Client{
|
||||
contentType: APIContentType,
|
||||
connectionString: connectionString,
|
||||
|
@ -30,6 +34,10 @@ func New(connectionString string) *Client {
|
|||
return c
|
||||
}
|
||||
|
||||
func (c *Client) ConnectionString() string {
|
||||
return c.connectionString
|
||||
}
|
||||
|
||||
// Client represents a client to a Photoprism application
|
||||
type Client struct {
|
||||
v1client *v1.V1Client
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
UID: aqohkx21cwlrrs71
|
||||
Slug: testalbum
|
||||
Type: album
|
||||
Title: TestAlbum
|
||||
Order: oldest
|
||||
Country: zz
|
||||
CreatedAt: 2021-02-13T21:27:02Z
|
||||
UpdatedAt: 2021-02-13T21:27:02Z
|
||||
DeletedAt: 2021-02-13T21:27:02.438478307Z
|
|
@ -0,0 +1,9 @@
|
|||
UID: aqohkx21dyhq6xa6
|
||||
Slug: testalbum
|
||||
Type: album
|
||||
Title: TestAlbum
|
||||
Order: oldest
|
||||
Country: zz
|
||||
CreatedAt: 2021-02-13T21:27:02Z
|
||||
UpdatedAt: 2021-02-13T21:27:02Z
|
||||
DeletedAt: 2021-02-13T21:27:02.460875532Z
|
|
@ -0,0 +1,9 @@
|
|||
UID: aqohkx21j9rj6w4f
|
||||
Slug: testalbum
|
||||
Type: album
|
||||
Title: TestAlbum
|
||||
Order: oldest
|
||||
Country: zz
|
||||
CreatedAt: 2021-02-13T21:27:02Z
|
||||
UpdatedAt: 2021-02-13T21:27:02Z
|
||||
DeletedAt: 2021-02-13T21:27:02.505591441Z
|
|
@ -0,0 +1,10 @@
|
|||
UID: aqohkx22im2tmqpd
|
||||
Slug: testalbum
|
||||
Type: album
|
||||
Title: TestAlbum
|
||||
Description: An updated album description
|
||||
Order: oldest
|
||||
Country: zz
|
||||
CreatedAt: 2021-02-13T21:27:02Z
|
||||
UpdatedAt: 2021-02-13T21:27:02.386442236Z
|
||||
DeletedAt: 2021-02-13T21:27:02.395711612Z
|
|
@ -0,0 +1,9 @@
|
|||
UID: aqohl0w1s0skc6f0
|
||||
Slug: testalbum
|
||||
Type: album
|
||||
Title: TestAlbum
|
||||
Order: oldest
|
||||
Country: zz
|
||||
CreatedAt: 2021-02-13T21:29:21Z
|
||||
UpdatedAt: 2021-02-13T21:29:21Z
|
||||
DeletedAt: 2021-02-13T21:29:20.538356219Z
|
|
@ -0,0 +1,9 @@
|
|||
UID: aqohl0w2dwab02xe
|
||||
Slug: testalbum
|
||||
Type: album
|
||||
Title: TestAlbum
|
||||
Order: oldest
|
||||
Country: zz
|
||||
CreatedAt: 2021-02-13T21:29:20Z
|
||||
UpdatedAt: 2021-02-13T21:29:20Z
|
||||
DeletedAt: 2021-02-13T21:29:20.486868765Z
|
|
@ -0,0 +1,10 @@
|
|||
UID: aqohl0w2xt57x1cb
|
||||
Slug: testalbum
|
||||
Type: album
|
||||
Title: TestAlbum
|
||||
Description: An updated album description
|
||||
Order: oldest
|
||||
Country: zz
|
||||
CreatedAt: 2021-02-13T21:29:20Z
|
||||
UpdatedAt: 2021-02-13T21:29:20.397458176Z
|
||||
DeletedAt: 2021-02-13T21:29:20.415107277Z
|
|
@ -0,0 +1,9 @@
|
|||
UID: aqohl0wdspiitn0a
|
||||
Slug: testalbum
|
||||
Type: album
|
||||
Title: TestAlbum
|
||||
Order: oldest
|
||||
Country: zz
|
||||
CreatedAt: 2021-02-13T21:29:20Z
|
||||
UpdatedAt: 2021-02-13T21:29:20Z
|
||||
DeletedAt: 2021-02-13T21:29:20.461857977Z
|
|
@ -114,6 +114,11 @@
|
|||
"tokens": null,
|
||||
"expiration": 1613695252131862322
|
||||
},
|
||||
"24227dba42c911f1f3250745252473200d95db38c9006bf6": {
|
||||
"user": "uqnzie01i1nypnt9",
|
||||
"tokens": null,
|
||||
"expiration": 1613856560374865002
|
||||
},
|
||||
"2521ed30985fb1991e3d1271cbf6e2b53840d614647361af": {
|
||||
"user": "uqnzie01i1nypnt9",
|
||||
"tokens": null,
|
||||
|
@ -184,6 +189,11 @@
|
|||
"tokens": null,
|
||||
"expiration": 1613676253240643293
|
||||
},
|
||||
"383cbd715f476ce738e23712a480e3fca123b68f16f2ee69": {
|
||||
"user": "uqnzie01i1nypnt9",
|
||||
"tokens": null,
|
||||
"expiration": 1613856561720200205
|
||||
},
|
||||
"3bd19dc60e5a515d2624f0d712db8471f433416935c2a045": {
|
||||
"user": "uqnzie01i1nypnt9",
|
||||
"tokens": null,
|
||||
|
@ -579,6 +589,11 @@
|
|||
"tokens": null,
|
||||
"expiration": 1613502517447074204
|
||||
},
|
||||
"a69b726d7a6bfab6bac0435a6673d5c390a732470c910f41": {
|
||||
"user": "uqnzie01i1nypnt9",
|
||||
"tokens": null,
|
||||
"expiration": 1613856423690963485
|
||||
},
|
||||
"a83cc511e399c1dab37468d0c64302bf4b68f7e3df5a1e0b": {
|
||||
"user": "uqnzie01i1nypnt9",
|
||||
"tokens": null,
|
||||
|
@ -649,6 +664,11 @@
|
|||
"tokens": null,
|
||||
"expiration": 1613693719704975163
|
||||
},
|
||||
"b9a554547ba1cc81f7d42ea5df395a50968294eb9b574d28": {
|
||||
"user": "uqnzie01i1nypnt9",
|
||||
"tokens": null,
|
||||
"expiration": 1613856422361372143
|
||||
},
|
||||
"bbdbf96d91d72d87fb819d31d7f175b733164975c1802243": {
|
||||
"user": "uqnzie01i1nypnt9",
|
||||
"tokens": null,
|
||||
|
|
Binary file not shown.
|
@ -3,7 +3,7 @@ UID: pqnzigq351j2fqgn
|
|||
Type: image
|
||||
Title: A really great photo!
|
||||
TitleSrc: manual
|
||||
Description: 'Sample App Description: 2021-02-13 13:17:39.073524303 -0800 PST m=+6.526679853'
|
||||
Description: 'Sample App Description: 2021-02-13 13:29:20.603412741 -0800 PST m=+6.504617892'
|
||||
DescriptionSrc: manual
|
||||
OriginalName: IMG_3044
|
||||
Year: -1
|
||||
|
@ -13,5 +13,5 @@ Details:
|
|||
Keywords: green, tambourine
|
||||
KeywordsSrc: manual
|
||||
CreatedAt: 2021-02-04T03:17:14.613092062Z
|
||||
UpdatedAt: 2021-02-13T21:17:39.081685026Z
|
||||
EditedAt: 2021-02-13T21:17:39Z
|
||||
UpdatedAt: 2021-02-13T21:29:20.611389111Z
|
||||
EditedAt: 2021-02-13T21:29:21Z
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/kris-nova/photoprism-client-go"
|
||||
)
|
||||
|
||||
// Trailing slash issue
|
||||
// https://github.com/kris-nova/photoprism-client-go/issues/2
|
||||
func TestRegressionIssue2(t *testing.T) {
|
||||
testStrings := []string{"localhost/", "localhost///////", "localhost//"}
|
||||
goal := "localhost"
|
||||
for _, str := range testStrings {
|
||||
client := photoprism.New(str)
|
||||
if client.ConnectionString() != goal {
|
||||
t.Error("Failed to trim suffix / in client connection string")
|
||||
t.FailNow()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue