Skip to content

Commit

Permalink
Revert the /graph changes.
Browse files Browse the repository at this point in the history
This revert will be reverted once v1.1 is released and has its own
release branch. Since we had already change on top of this, there was
no cleaner way of cutting those changes out.

This commit reverts the following commits:

Revert "Update backend helpers and templates to new url schema"
This reverts commit fc6cdd0.

Revert "Refactor graph.js"
This reverts commit 445fac5.

Revert "Use query parameters in the url"
This reverts commit 3e18d86.

Revert "Point to correct place for GraphLinkForExpression"
This reverts commit 3da825f.

Assets are also updated.
  • Loading branch information
beorn7 committed Sep 2, 2016
1 parent a88e950 commit aa43d34
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 267 deletions.
4 changes: 2 additions & 2 deletions template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,12 @@ func TestTemplateExpansion(t *testing.T) {
{
// graphLink.
text: "{{ graphLink \"up\" }}",
output: "/graph?g0.expr=up&g0.tab=0",
output: "/graph#%5B%7B%22expr%22%3A%22up%22%2C%22tab%22%3A0%7D%5D",
},
{
// tableLink.
text: "{{ tableLink \"up\" }}",
output: "/graph?g0.expr=up&g0.tab=1",
output: "/graph#%5B%7B%22expr%22%3A%22up%22%2C%22tab%22%3A1%7D%5D",
},
{
// tmpl.
Expand Down
16 changes: 12 additions & 4 deletions util/strutil/strconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"fmt"
"net/url"
"regexp"
"strings"
)

var (
Expand All @@ -26,15 +27,22 @@ var (
// TableLinkForExpression creates an escaped relative link to the table view of
// the provided expression.
func TableLinkForExpression(expr string) string {
escapedExpression := url.QueryEscape(expr)
return fmt.Sprintf("/graph?g0.expr=%s&g0.tab=1", escapedExpression)
// url.QueryEscape percent-escapes everything except spaces, for which it
// uses "+". However, in the non-query part of a URI, only percent-escaped
// spaces are legal, so we need to manually replace "+" with "%20" after
// query-escaping the string.
//
// See also:
// http://stackoverflow.com/questions/1634271/url-encoding-the-space-character-or-20.
urlData := url.QueryEscape(fmt.Sprintf(`[{"expr":%q,"tab":1}]`, expr))
return fmt.Sprintf("/graph#%s", strings.Replace(urlData, "+", "%20", -1))
}

// GraphLinkForExpression creates an escaped relative link to the graph view of
// the provided expression.
func GraphLinkForExpression(expr string) string {
escapedExpression := url.QueryEscape(expr)
return fmt.Sprintf("/graph?g0.expr=%s&g0.tab=0", escapedExpression)
urlData := url.QueryEscape(fmt.Sprintf(`[{"expr":%q,"tab":0}]`, expr))
return fmt.Sprintf("/graph#%s", strings.Replace(urlData, "+", "%20", -1))
}

// SanitizeLabelName replaces anything that doesn't match
Expand Down
49 changes: 0 additions & 49 deletions util/strutil/strconv_test.go

This file was deleted.

Loading

0 comments on commit aa43d34

Please sign in to comment.