From 7bae7997a7b55bf71c8c572cfbbc23b16829af39 Mon Sep 17 00:00:00 2001 From: Kasey Date: Mon, 12 Mar 2018 16:51:08 -0400 Subject: [PATCH] fix(structuredData): data should return DataPath not dataset Path --- api/datasets.go | 9 +++++++-- core/datasets.go | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/api/datasets.go b/api/datasets.go index 9a6b7cfea..11853ff78 100644 --- a/api/datasets.go +++ b/api/datasets.go @@ -5,12 +5,13 @@ import ( "encoding/json" "errors" "fmt" - "github.com/qri-io/dataset" "net/http" "os" "path/filepath" "strings" + "github.com/qri-io/dataset" + util "github.com/datatogether/api/apiutil" "github.com/qri-io/cafs/memfs" "github.com/qri-io/dataset/dsutil" @@ -605,6 +606,10 @@ func (h DatasetHandlers) dataHandler(w http.ResponseWriter, r *http.Request) { return } + if err := repo.CanonicalizeDatasetRef(h.repo, &d); err != nil { + util.WriteErrResponse(w, http.StatusInternalServerError, err) + } + limit, err := util.ReqParamInt("limit", r) if err != nil { limit = defaultDataLimit @@ -632,7 +637,7 @@ func (h DatasetHandlers) dataHandler(w http.ResponseWriter, r *http.Request) { page := util.PageFromRequest(r) dataResponse := DataResponse{ - Path: p.Path, + Path: data.Path, Data: json.RawMessage(data.Data), } if err := util.WritePageResponse(w, dataResponse, r, page); err != nil { diff --git a/core/datasets.go b/core/datasets.go index 5f07e445d..3feccfdec 100644 --- a/core/datasets.go +++ b/core/datasets.go @@ -696,7 +696,7 @@ func (r *DatasetRequests) StructuredData(p *StructuredDataParams, data *Structur } *data = StructuredData{ - Path: p.Path, + Path: ds.DataPath, Data: buf.Bytes(), } return nil