porting all github actions from bluesky-social/indigo to tangled CI

syntax: fix AT-URI Path() impl

Changed files
+30 -5
atproto
+4 -4
atproto/syntax/aturi.go
··· 62 62 // Returns path segment, without leading slash, as would be used in an atproto repository key. Or empty string if there is no path. 63 63 func (n ATURI) Path() string { 64 64 parts := strings.SplitN(string(n), "/", 5) 65 - if len(parts) < 3 { 65 + if len(parts) < 4 { 66 66 // something has gone wrong (would not validate) 67 67 return "" 68 68 } 69 - if len(parts) == 3 { 70 - return parts[2] 69 + if len(parts) == 4 { 70 + return parts[3] 71 71 } 72 - return parts[2] + "/" + parts[3] 72 + return parts[3] + "/" + parts[4] 73 73 } 74 74 75 75 // Returns a valid NSID if there is one in the appropriate part of the path, otherwise empty.
+26 -1
atproto/syntax/aturi_test.go
··· 20 20 if len(line) == 0 || line[0] == '#' { 21 21 continue 22 22 } 23 - _, err := ParseATURI(line) 23 + aturi, err := ParseATURI(line) 24 24 if err != nil { 25 25 fmt.Println("FAILED, GOOD: " + line) 26 26 } 27 27 assert.NoError(err) 28 + 29 + // check that Path() is working 30 + col := aturi.Collection() 31 + rkey := aturi.RecordKey() 32 + if rkey != "" { 33 + assert.Equal(col.String()+"/"+rkey.String(), aturi.Path()) 34 + } else if col != "" { 35 + assert.Equal(col.String(), aturi.Path()) 36 + } 28 37 } 29 38 assert.NoError(scanner.Err()) 30 39 } ··· 67 76 rkey := uri.RecordKey() 68 77 assert.Equal(parts[3], rkey.String()) 69 78 } 79 + } 70 80 81 + func TestATURIPath(t *testing.T) { 82 + assert := assert.New(t) 83 + 84 + uri1, err := ParseATURI("at://did:abc:123/io.nsid.someFunc/record-key") 85 + assert.NoError(err) 86 + assert.Equal("io.nsid.someFunc/record-key", uri1.Path()) 87 + 88 + uri2, err := ParseATURI("at://did:abc:123/io.nsid.someFunc") 89 + assert.NoError(err) 90 + assert.Equal("io.nsid.someFunc", uri2.Path()) 91 + 92 + uri3, err := ParseATURI("at://did:abc:123") 93 + assert.NoError(err) 94 + assert.Equal("", uri3.Path()) 71 95 } 72 96 73 97 func TestATURINormalize(t *testing.T) { ··· 93 117 _ = bad.RecordKey() 94 118 _ = bad.Normalize() 95 119 _ = bad.String() 120 + _ = bad.Path() 96 121 } 97 122 }