~aleteoryx/tclfeed-bsky

ref: c2a8695d26de93111c807e8dd30f111614228c44 tclfeed-bsky/src/at.tcl -rw-r--r-- 486 bytes
c2a8695dAleteoryx oops 27 days ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
namespace eval at {
  # conformant enough, i hope
  proc uri {uri} {
    if {[string first "at://" $uri] != 0} return
    set uri [string range $uri 5 end]
    set uri [split $uri /]

    switch -- [llength $uri] {
      1 { return [list authority [lindex $uri 0]] }
      2 { return [list authority [lindex $uri 0] collection [lindex $uri 1]] }
      3 { return [list authority [lindex $uri 0] collection [lindex $uri 1] rkey [lindex $uri 2]] }
      default { return {} }
    }
  }
}