~aleteoryx/tclfeed-bsky

tclfeed-bsky/src/at.tcl -rw-r--r-- 486 bytes
45b4726bAleteoryx more heuristic tweaks 25 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 {} }
    }
  }
}