Skip to content

Commit eb2ef62

Browse files
ZachSmithusku1ik
authored andcommitted
Improved IPFS support (based on ipfs/kubo#1678 (comment))
1 parent 2b033f1 commit eb2ef62

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## master
44

55
* Added playback from stdin: `cat demo.json | asciinema play -`
6-
* Added playback from IPFS: `asciinema play ipfs://ipfs/QmcdXYJp6e4zNuimuGeWPwNMHQdxuqWmKx7NhZofQ1nw2V`
6+
* Added playback from IPFS: `asciinema play ipfs:/ipfs/QmcdXYJp6e4zNuimuGeWPwNMHQdxuqWmKx7NhZofQ1nw2V`
77
* Added playback from asciicast page URL: `asciinema play https://asciinema.org/a/22124`
88
* `-q/--quiet` option added to `rec` command
99
* Fixed handling of partial UTF-8 sequences in recorded stdout

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ Playing from stdin:
114114
cat /path/to/asciicast.json | asciinema play -
115115
curl -sL https://asciinema.org/a/21310.json | asciinema play -
116116

117+
Playing from IPFS:
118+
119+
asciinema play ipfs:/ipfs/QmcdXYJp6e4zNuimuGeWPwNMHQdxuqWmKx7NhZofQ1nw2V
120+
asciinema play fs:/ipfs/QmcdXYJp6e4zNuimuGeWPwNMHQdxuqWmKx7NhZofQ1nw2V
121+
117122
Available options:
118123

119124
* `-w, --max-wait=<sec>` - Reduce replayed terminal inactivity to max <sec> seconds

asciicast/asciicast.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,10 @@ func getSource(url string) (io.ReadCloser, error) {
101101
var isHTML bool
102102
var err error
103103

104-
if strings.HasPrefix(url, "ipfs://") {
105-
url = fmt.Sprintf("https://ipfs.io/%v", url[7:len(url)])
104+
if strings.HasPrefix(url, "ipfs:/") {
105+
url = fmt.Sprintf("https://ipfs.io/%v", url[6:])
106+
} else if strings.HasPrefix(url, "fs:/") {
107+
url = fmt.Sprintf("https://ipfs.io/%v", url[4:])
106108
}
107109

108110
if url == "-" {

0 commit comments

Comments
 (0)