Skip to content

Commit

Permalink
Merge pull request #81 from Comcast/dev
Browse files Browse the repository at this point in the history
merge code from dev v1.20 to master
  • Loading branch information
holidaymike committed Jun 18, 2018
2 parents a815097 + 27a54fc commit 47d0a24
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 19 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,7 +4,9 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
This `CHANGELOG.md` implements the spirit of http://keepachangelog.com/.

## [1.20](https://github.com/Comcast/eel/compare/v1.19...dev) - [Unreleased]
## [1.21](https://github.com/Comcast/eel/compare/v1.20...dev) - [Unreleased]

## [1.20](https://github.com/Comcast/eel/compare/v1.19...v1.20) - 2018-06-18

## [1.19](https://github.com/Comcast/eel/compare/v1.18...v1.19) - 2018-05-24

Expand Down
6 changes: 3 additions & 3 deletions jtl/lexer.go
Expand Up @@ -145,10 +145,10 @@ func (l *lexer) run() {

// emit passes an item back to the client.
func (l *lexer) emit(t lexItemType) {
// only trim tab and newline (formattings) but retain plain old white space
// leave the original text in its own flavor, and don't trim tab and newline and white space
token := l.input[l.start:l.pos]
token = strings.TrimLeft(token, "\t\n")
token = strings.TrimRight(token, "\t\n")
//token = strings.TrimLeft(token, "\t\n")
//token = strings.TrimRight(token, "\t\n")
// handle escapes
if token == escapedLeftMeta {
token = leftMeta
Expand Down
53 changes: 38 additions & 15 deletions test/misc_test.go
Expand Up @@ -18,6 +18,7 @@ package test

import (
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"testing"
Expand Down Expand Up @@ -1194,26 +1195,30 @@ func TestParserWhiteSpace(t *testing.T) {
props := GetConfig(Gctx).CustomProperties
props["ServiceUrl"] = ts.URL
test = `foo-
{{eval(
'/accountId',
'{{curl(
'POST',
'{{prop(
'ServiceUrl'
)}}'
)}}'
)}}
-
{{ident(
'bar'
)}}
-bar`
{{eval(
'/accountId',
'{{curl(
'POST',
'{{prop(
'ServiceUrl'
)}}'
)}}'
)}}
-
{{ident(
'bar'
)}}
-bar`
jexpr, err := NewJExpr(test)
if err != nil {
t.Errorf("error: %s\n", err.Error())
}
result := jexpr.Execute(Gctx, e1)
expected := "foo-42-bar-bar"
expected := `foo-
42
-
bar
-bar`
if result.(string) != expected {
t.Errorf("wrong parsing result: %v expected: %s\n", result, expected)
}
Expand All @@ -1237,6 +1242,24 @@ func TestEscapingSingleQuotes(t *testing.T) {
}
}

func TestEscapingSingleQuotes2(t *testing.T) {
initTests("../config-handlers")
e1, err := NewJDocFromString(event1)
if err != nil {
t.Fatal("could not get event1")
}
test := fmt.Sprintf("foo\n{{ident('{{ident('{{ident('this isn\\'t breaking any more')}}')}}')}}\nfoo")
jexpr, err := NewJExpr(test)
if err != nil {
t.Errorf("parsing error: %s\n", err.Error())
}
result := jexpr.Execute(Gctx, e1)
expected := "foo\nthis isn't breaking any more\nfoo"
if result.(string) != expected {
t.Errorf("wrong parsing result: %v expected: %s\n", result, expected)
}
}

func TestParserDeepNesting(t *testing.T) {
initTests("../config-handlers")
e1, err := NewJDocFromString(event1)
Expand Down

0 comments on commit 47d0a24

Please sign in to comment.