appview/repo: strip .tar.gz suffix from archive ref #1

merged
opened by zzstoatzz.io targeting master from fix-archive-tar-gz-extension

allows /archive/main.tar.gz to work like /archive/main for compatibility with github-style archive URLs.

repro:

# before: returns 503 HTML
curl -sL "https://tangled.org/zzstoatzz.io/zat/archive/main.tar.gz" | file -

# after: should return gzip compressed data
curl -sL "https://tangled.org/zzstoatzz.io/zat/archive/main" | file -
Changed files
+1
appview
repo
+1
appview/repo/archive.go
··· 18 18 l := rp.logger.With("handler", "DownloadArchive") 19 19 ref := chi.URLParam(r, "ref") 20 20 ref, _ = url.PathUnescape(ref) 21 + ref = strings.TrimSuffix(ref, ".tar.gz") 21 22 f, err := rp.repoResolver.Resolve(r) 22 23 if err != nil { 23 24 l.Error("failed to get repo and knot", "err", err)