File tree Expand file tree Collapse file tree 3 files changed +8
-2
lines changed
Expand file tree Collapse file tree 3 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import (
1010 "strings"
1111 "time"
1212 "unicode"
13+ "unicode/utf8"
1314
1415 i "github.com/taskcluster/json-e/interpreter"
1516)
@@ -200,7 +201,7 @@ var builtin = map[string]interface{}{
200201 "len" : i .WrapFunction (func (v interface {}) (float64 , error ) {
201202 switch val := v .(type ) {
202203 case string :
203- return float64 (len (val )), nil
204+ return float64 (utf8 . RuneCountInString (val )), nil
204205 case []interface {}:
205206 return float64 (len (val )), nil
206207 }
Original file line number Diff line number Diff line change @@ -1530,6 +1530,11 @@ context: {key: 'abc'}
15301530template : {$eval: 'len(key)'}
15311531result : 3
15321532---
1533+ title : len of grinning face unicode character
1534+ context : {key: "\U0001F601"}
1535+ template : {$eval: 'len(key)'}
1536+ result : 1
1537+ ---
15331538title : len (4)
15341539context : {key: [1,2,3]}
15351540template : {$eval: 'len("abc")'}
Original file line number Diff line number Diff line change @@ -94,7 +94,7 @@ module.exports = (context) => {
9494
9595 define ( 'len' , builtins , {
9696 argumentTests : [ 'string|array' ] ,
97- invoke : obj => obj . length ,
97+ invoke : obj => Array . from ( obj ) . length ,
9898 } ) ;
9999
100100 define ( 'strip' , builtins , {
You can’t perform that action at this time.
0 commit comments