Comparing version 1.3.0 to 1.3.1
{ | ||
"name": "rest", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"main": "./browser.js", | ||
@@ -5,0 +5,0 @@ "moduleType": ["amd", "node"], |
{ | ||
"name": "rest", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "RESTful HTTP client library", | ||
@@ -5,0 +5,0 @@ "keywords": ["rest", "http", "client", "rest-template", "spring", "cujojs"], |
@@ -238,2 +238,5 @@ rest.js | ||
1.3.1 | ||
- fix to allow numbers and boolean values as parameters to URI Template expansion. | ||
1.3.0 | ||
@@ -240,0 +243,0 @@ - response.follow() for easy traversal of hypermedia APIs |
@@ -23,160 +23,169 @@ /* | ||
buster.testCase('rest/util/uriTempalte', { | ||
setUp: function () { | ||
params = { | ||
count : ['one', 'two', 'three'], | ||
dom : ['example', 'com'], | ||
dub : 'me/too', | ||
hello : 'Hello World!', | ||
half : '50%', | ||
'var' : 'value', | ||
who : 'fred', | ||
base : 'http://example.com/home/', | ||
path : '/foo/bar', | ||
list : ['red', 'green', 'blue'], | ||
keys : { semi: ';', dot: '.', comma: ',' }, | ||
v : '6', | ||
x : '1024', | ||
y : '768', | ||
empty : '', | ||
'empty_keys' : {}, | ||
undef : null | ||
}; | ||
}, | ||
'should support examples in rfc6570': { | ||
setUp: function () { | ||
params = { | ||
count : ['one', 'two', 'three'], | ||
dom : ['example', 'com'], | ||
dub : 'me/too', | ||
hello : 'Hello World!', | ||
half : '50%', | ||
'var' : 'value', | ||
who : 'fred', | ||
base : 'http://example.com/home/', | ||
path : '/foo/bar', | ||
list : ['red', 'green', 'blue'], | ||
keys : { semi: ';', dot: '.', comma: ',' }, | ||
v : '6', | ||
x : '1024', | ||
y : '768', | ||
empty : '', | ||
'empty_keys' : {}, | ||
undef : null | ||
}; | ||
}, | ||
'3.2.1. Variable Expansion': function () { | ||
assert.same(uriTemplate.expand('{count}', params), 'one,two,three'); | ||
assert.same(uriTemplate.expand('{count*}', params), 'one,two,three'); | ||
assert.same(uriTemplate.expand('{/count}', params), '/one,two,three'); | ||
assert.same(uriTemplate.expand('{/count*}', params), '/one/two/three'); | ||
assert.same(uriTemplate.expand('{;count}', params), ';count=one,two,three'); | ||
assert.same(uriTemplate.expand('{;count*}', params), ';count=one;count=two;count=three'); | ||
assert.same(uriTemplate.expand('{?count}', params), '?count=one,two,three'); | ||
assert.same(uriTemplate.expand('{?count*}', params), '?count=one&count=two&count=three'); | ||
assert.same(uriTemplate.expand('{&count*}', params), '&count=one&count=two&count=three'); | ||
}, | ||
'3.2.2. Simple String Expansion: {var}': function () { | ||
assert.same(uriTemplate.expand('{var}', params), 'value'); | ||
assert.same(uriTemplate.expand('{hello}', params), 'Hello%20World%21'); | ||
assert.same(uriTemplate.expand('{half}', params), '50%25'); | ||
assert.same(uriTemplate.expand('O{empty}X', params), 'OX'); | ||
assert.same(uriTemplate.expand('O{undef}X', params), 'OX'); | ||
assert.same(uriTemplate.expand('{x,y}', params), '1024,768'); | ||
assert.same(uriTemplate.expand('{x,hello,y}', params), '1024,Hello%20World%21,768'); | ||
assert.same(uriTemplate.expand('?{x,empty}', params), '?1024,'); | ||
assert.same(uriTemplate.expand('?{x,undef}', params), '?1024'); | ||
assert.same(uriTemplate.expand('?{undef,y}', params), '?768'); | ||
assert.same(uriTemplate.expand('{var:3}', params), 'val'); | ||
assert.same(uriTemplate.expand('{var:30}', params), 'value'); | ||
assert.same(uriTemplate.expand('{list}', params), 'red,green,blue'); | ||
assert.same(uriTemplate.expand('{list*}', params), 'red,green,blue'); | ||
assert.same(uriTemplate.expand('{keys}', params), 'semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{keys*}', params), 'semi=%3B,dot=.,comma=%2C'); | ||
}, | ||
'3.2.3. Reserved Expansion: {+var}': function () { | ||
assert.same(uriTemplate.expand('{+var}', params), 'value'); | ||
assert.same(uriTemplate.expand('{+hello}', params), 'Hello%20World!'); | ||
assert.same(uriTemplate.expand('{+half}', params), '50%25'); | ||
'3.2.1. Variable Expansion': function () { | ||
assert.same(uriTemplate.expand('{count}', params), 'one,two,three'); | ||
assert.same(uriTemplate.expand('{count*}', params), 'one,two,three'); | ||
assert.same(uriTemplate.expand('{/count}', params), '/one,two,three'); | ||
assert.same(uriTemplate.expand('{/count*}', params), '/one/two/three'); | ||
assert.same(uriTemplate.expand('{;count}', params), ';count=one,two,three'); | ||
assert.same(uriTemplate.expand('{;count*}', params), ';count=one;count=two;count=three'); | ||
assert.same(uriTemplate.expand('{?count}', params), '?count=one,two,three'); | ||
assert.same(uriTemplate.expand('{?count*}', params), '?count=one&count=two&count=three'); | ||
assert.same(uriTemplate.expand('{&count*}', params), '&count=one&count=two&count=three'); | ||
}, | ||
'3.2.2. Simple String Expansion: {var}': function () { | ||
assert.same(uriTemplate.expand('{var}', params), 'value'); | ||
assert.same(uriTemplate.expand('{hello}', params), 'Hello%20World%21'); | ||
assert.same(uriTemplate.expand('{half}', params), '50%25'); | ||
assert.same(uriTemplate.expand('O{empty}X', params), 'OX'); | ||
assert.same(uriTemplate.expand('O{undef}X', params), 'OX'); | ||
assert.same(uriTemplate.expand('{x,y}', params), '1024,768'); | ||
assert.same(uriTemplate.expand('{x,hello,y}', params), '1024,Hello%20World%21,768'); | ||
assert.same(uriTemplate.expand('?{x,empty}', params), '?1024,'); | ||
assert.same(uriTemplate.expand('?{x,undef}', params), '?1024'); | ||
assert.same(uriTemplate.expand('?{undef,y}', params), '?768'); | ||
assert.same(uriTemplate.expand('{var:3}', params), 'val'); | ||
assert.same(uriTemplate.expand('{var:30}', params), 'value'); | ||
assert.same(uriTemplate.expand('{list}', params), 'red,green,blue'); | ||
assert.same(uriTemplate.expand('{list*}', params), 'red,green,blue'); | ||
assert.same(uriTemplate.expand('{keys}', params), 'semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{keys*}', params), 'semi=%3B,dot=.,comma=%2C'); | ||
}, | ||
'3.2.3. Reserved Expansion: {+var}': function () { | ||
assert.same(uriTemplate.expand('{+var}', params), 'value'); | ||
assert.same(uriTemplate.expand('{+hello}', params), 'Hello%20World!'); | ||
assert.same(uriTemplate.expand('{+half}', params), '50%25'); | ||
assert.same(uriTemplate.expand('{base}index', params), 'http%3A%2F%2Fexample.com%2Fhome%2Findex'); | ||
assert.same(uriTemplate.expand('{+base}index', params), 'http://example.com/home/index'); | ||
assert.same(uriTemplate.expand('O{+empty}X', params), 'OX'); | ||
assert.same(uriTemplate.expand('O{+undef}X', params), 'OX'); | ||
assert.same(uriTemplate.expand('{base}index', params), 'http%3A%2F%2Fexample.com%2Fhome%2Findex'); | ||
assert.same(uriTemplate.expand('{+base}index', params), 'http://example.com/home/index'); | ||
assert.same(uriTemplate.expand('O{+empty}X', params), 'OX'); | ||
assert.same(uriTemplate.expand('O{+undef}X', params), 'OX'); | ||
assert.same(uriTemplate.expand('{+path}/here', params), '/foo/bar/here'); | ||
assert.same(uriTemplate.expand('here?ref={+path}', params), 'here?ref=/foo/bar'); | ||
assert.same(uriTemplate.expand('up{+path}{var}/here', params), 'up/foo/barvalue/here'); | ||
assert.same(uriTemplate.expand('{+x,hello,y}', params), '1024,Hello%20World!,768'); | ||
assert.same(uriTemplate.expand('{+path,x}/here', params), '/foo/bar,1024/here'); | ||
assert.same(uriTemplate.expand('{+path}/here', params), '/foo/bar/here'); | ||
assert.same(uriTemplate.expand('here?ref={+path}', params), 'here?ref=/foo/bar'); | ||
assert.same(uriTemplate.expand('up{+path}{var}/here', params), 'up/foo/barvalue/here'); | ||
assert.same(uriTemplate.expand('{+x,hello,y}', params), '1024,Hello%20World!,768'); | ||
assert.same(uriTemplate.expand('{+path,x}/here', params), '/foo/bar,1024/here'); | ||
assert.same(uriTemplate.expand('{+path:6}/here', params), '/foo/b/here'); | ||
assert.same(uriTemplate.expand('{+list}', params), 'red,green,blue'); | ||
assert.same(uriTemplate.expand('{+list*}', params), 'red,green,blue'); | ||
assert.same(uriTemplate.expand('{+keys}', params), 'semi,;,dot,.,comma,,'); | ||
assert.same(uriTemplate.expand('{+keys*}', params), 'semi=;,dot=.,comma=,'); | ||
assert.same(uriTemplate.expand('{+path:6}/here', params), '/foo/b/here'); | ||
assert.same(uriTemplate.expand('{+list}', params), 'red,green,blue'); | ||
assert.same(uriTemplate.expand('{+list*}', params), 'red,green,blue'); | ||
assert.same(uriTemplate.expand('{+keys}', params), 'semi,;,dot,.,comma,,'); | ||
assert.same(uriTemplate.expand('{+keys*}', params), 'semi=;,dot=.,comma=,'); | ||
}, | ||
'3.2.4. Fragment Expansion: {#var}': function () { | ||
assert.same(uriTemplate.expand('{#var}', params), '#value'); | ||
assert.same(uriTemplate.expand('{#hello}', params), '#Hello%20World!'); | ||
assert.same(uriTemplate.expand('{#half}', params), '#50%25'); | ||
assert.same(uriTemplate.expand('foo{#empty}', params), 'foo#'); | ||
assert.same(uriTemplate.expand('foo{#undef}', params), 'foo'); | ||
assert.same(uriTemplate.expand('{#x,hello,y}', params), '#1024,Hello%20World!,768'); | ||
assert.same(uriTemplate.expand('{#path,x}/here', params), '#/foo/bar,1024/here'); | ||
assert.same(uriTemplate.expand('{#path:6}/here', params), '#/foo/b/here'); | ||
assert.same(uriTemplate.expand('{#list}', params), '#red,green,blue'); | ||
assert.same(uriTemplate.expand('{#list*}', params), '#red,green,blue'); | ||
assert.same(uriTemplate.expand('{#keys}', params), '#semi,;,dot,.,comma,,'); | ||
assert.same(uriTemplate.expand('{#keys*}', params), '#semi=;,dot=.,comma=,'); | ||
}, | ||
'3.2.5. Label Expansion with Dot-Prefix: {.var}': function () { | ||
assert.same(uriTemplate.expand('{.who}', params), '.fred'); | ||
assert.same(uriTemplate.expand('{.who,who}', params), '.fred.fred'); | ||
assert.same(uriTemplate.expand('{.half,who}', params), '.50%25.fred'); | ||
assert.same(uriTemplate.expand('www{.dom*}', params), 'www.example.com'); | ||
assert.same(uriTemplate.expand('X{.var}', params), 'X.value'); | ||
assert.same(uriTemplate.expand('X{.empty}', params), 'X.'); | ||
assert.same(uriTemplate.expand('X{.undef}', params), 'X'); | ||
assert.same(uriTemplate.expand('X{.var:3}', params), 'X.val'); | ||
assert.same(uriTemplate.expand('X{.list}', params), 'X.red,green,blue'); | ||
assert.same(uriTemplate.expand('X{.list*}', params), 'X.red.green.blue'); | ||
assert.same(uriTemplate.expand('X{.keys}', params), 'X.semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('X{.keys*}', params), 'X.semi=%3B.dot=..comma=%2C'); | ||
assert.same(uriTemplate.expand('X{.empty_keys}', params), 'X'); | ||
assert.same(uriTemplate.expand('X{.empty_keys*}', params), 'X'); | ||
}, | ||
'3.2.6. Path Segment Expansion: {/var}': function () { | ||
assert.same(uriTemplate.expand('{/who}', params), '/fred'); | ||
assert.same(uriTemplate.expand('{/who,who}', params), '/fred/fred'); | ||
assert.same(uriTemplate.expand('{/half,who}', params), '/50%25/fred'); | ||
assert.same(uriTemplate.expand('{/who,dub}', params), '/fred/me%2Ftoo'); | ||
assert.same(uriTemplate.expand('{/var}', params), '/value'); | ||
assert.same(uriTemplate.expand('{/var,empty}', params), '/value/'); | ||
assert.same(uriTemplate.expand('{/var,undef}', params), '/value'); | ||
assert.same(uriTemplate.expand('{/var,x}/here', params), '/value/1024/here'); | ||
assert.same(uriTemplate.expand('{/var:1,var}', params), '/v/value'); | ||
assert.same(uriTemplate.expand('{/list}', params), '/red,green,blue'); | ||
assert.same(uriTemplate.expand('{/list*}', params), '/red/green/blue'); | ||
assert.same(uriTemplate.expand('{/list*,path:4}', params), '/red/green/blue/%2Ffoo'); | ||
assert.same(uriTemplate.expand('{/keys}', params), '/semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{/keys*}', params), '/semi=%3B/dot=./comma=%2C'); | ||
}, | ||
'3.2.7. Path-Style Parameter Expansion: {;var}': function () { | ||
assert.same(uriTemplate.expand('{;who}', params), ';who=fred'); | ||
assert.same(uriTemplate.expand('{;half}', params), ';half=50%25'); | ||
assert.same(uriTemplate.expand('{;empty}', params), ';empty'); | ||
assert.same(uriTemplate.expand('{;v,empty,who}', params), ';v=6;empty;who=fred'); | ||
assert.same(uriTemplate.expand('{;v,bar,who}', params), ';v=6;who=fred'); | ||
assert.same(uriTemplate.expand('{;x,y}', params), ';x=1024;y=768'); | ||
assert.same(uriTemplate.expand('{;x,y,empty}', params), ';x=1024;y=768;empty'); | ||
assert.same(uriTemplate.expand('{;x,y,undef}', params), ';x=1024;y=768'); | ||
assert.same(uriTemplate.expand('{;hello:5}', params), ';hello=Hello'); | ||
assert.same(uriTemplate.expand('{;list}', params), ';list=red,green,blue'); | ||
assert.same(uriTemplate.expand('{;list*}', params), ';list=red;list=green;list=blue'); | ||
assert.same(uriTemplate.expand('{;keys}', params), ';keys=semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{;keys*}', params), ';semi=%3B;dot=.;comma=%2C'); | ||
}, | ||
'3.2.8. Form-Style Query Expansion: {?var}': function () { | ||
assert.same(uriTemplate.expand('{?who}', params), '?who=fred'); | ||
assert.same(uriTemplate.expand('{?half}', params), '?half=50%25'); | ||
assert.same(uriTemplate.expand('{?x,y}', params), '?x=1024&y=768'); | ||
assert.same(uriTemplate.expand('{?x,y,empty}', params), '?x=1024&y=768&empty='); | ||
assert.same(uriTemplate.expand('{?x,y,undef}', params), '?x=1024&y=768'); | ||
assert.same(uriTemplate.expand('{?var:3}', params), '?var=val'); | ||
assert.same(uriTemplate.expand('{?list}', params), '?list=red,green,blue'); | ||
assert.same(uriTemplate.expand('{?list*}', params), '?list=red&list=green&list=blue'); | ||
assert.same(uriTemplate.expand('{?keys}', params), '?keys=semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{?keys*}', params), '?semi=%3B&dot=.&comma=%2C'); | ||
}, | ||
'3.2.9. Form-Style Query Continuation: {&var}': function () { | ||
assert.same(uriTemplate.expand('{&who}', params), '&who=fred'); | ||
assert.same(uriTemplate.expand('{&half}', params), '&half=50%25'); | ||
assert.same(uriTemplate.expand('?fixed=yes{&x}', params), '?fixed=yes&x=1024'); | ||
assert.same(uriTemplate.expand('{&x,y,empty}', params), '&x=1024&y=768&empty='); | ||
assert.same(uriTemplate.expand('{&x,y,undef}', params), '&x=1024&y=768'); | ||
assert.same(uriTemplate.expand('{&var:3}', params), '&var=val'); | ||
assert.same(uriTemplate.expand('{&list}', params), '&list=red,green,blue'); | ||
assert.same(uriTemplate.expand('{&list*}', params), '&list=red&list=green&list=blue'); | ||
assert.same(uriTemplate.expand('{&keys}', params), '&keys=semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{&keys*}', params), '&semi=%3B&dot=.&comma=%2C'); | ||
} | ||
}, | ||
'3.2.4. Fragment Expansion: {#var}': function () { | ||
assert.same(uriTemplate.expand('{#var}', params), '#value'); | ||
assert.same(uriTemplate.expand('{#hello}', params), '#Hello%20World!'); | ||
assert.same(uriTemplate.expand('{#half}', params), '#50%25'); | ||
assert.same(uriTemplate.expand('foo{#empty}', params), 'foo#'); | ||
assert.same(uriTemplate.expand('foo{#undef}', params), 'foo'); | ||
assert.same(uriTemplate.expand('{#x,hello,y}', params), '#1024,Hello%20World!,768'); | ||
assert.same(uriTemplate.expand('{#path,x}/here', params), '#/foo/bar,1024/here'); | ||
assert.same(uriTemplate.expand('{#path:6}/here', params), '#/foo/b/here'); | ||
assert.same(uriTemplate.expand('{#list}', params), '#red,green,blue'); | ||
assert.same(uriTemplate.expand('{#list*}', params), '#red,green,blue'); | ||
assert.same(uriTemplate.expand('{#keys}', params), '#semi,;,dot,.,comma,,'); | ||
assert.same(uriTemplate.expand('{#keys*}', params), '#semi=;,dot=.,comma=,'); | ||
'should support number params': function () { | ||
assert.same(uriTemplate.expand('http://example.com/{a}', { a: 123 }), 'http://example.com/123'); | ||
}, | ||
'3.2.5. Label Expansion with Dot-Prefix: {.var}': function () { | ||
assert.same(uriTemplate.expand('{.who}', params), '.fred'); | ||
assert.same(uriTemplate.expand('{.who,who}', params), '.fred.fred'); | ||
assert.same(uriTemplate.expand('{.half,who}', params), '.50%25.fred'); | ||
assert.same(uriTemplate.expand('www{.dom*}', params), 'www.example.com'); | ||
assert.same(uriTemplate.expand('X{.var}', params), 'X.value'); | ||
assert.same(uriTemplate.expand('X{.empty}', params), 'X.'); | ||
assert.same(uriTemplate.expand('X{.undef}', params), 'X'); | ||
assert.same(uriTemplate.expand('X{.var:3}', params), 'X.val'); | ||
assert.same(uriTemplate.expand('X{.list}', params), 'X.red,green,blue'); | ||
assert.same(uriTemplate.expand('X{.list*}', params), 'X.red.green.blue'); | ||
assert.same(uriTemplate.expand('X{.keys}', params), 'X.semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('X{.keys*}', params), 'X.semi=%3B.dot=..comma=%2C'); | ||
assert.same(uriTemplate.expand('X{.empty_keys}', params), 'X'); | ||
assert.same(uriTemplate.expand('X{.empty_keys*}', params), 'X'); | ||
}, | ||
'3.2.6. Path Segment Expansion: {/var}': function () { | ||
assert.same(uriTemplate.expand('{/who}', params), '/fred'); | ||
assert.same(uriTemplate.expand('{/who,who}', params), '/fred/fred'); | ||
assert.same(uriTemplate.expand('{/half,who}', params), '/50%25/fred'); | ||
assert.same(uriTemplate.expand('{/who,dub}', params), '/fred/me%2Ftoo'); | ||
assert.same(uriTemplate.expand('{/var}', params), '/value'); | ||
assert.same(uriTemplate.expand('{/var,empty}', params), '/value/'); | ||
assert.same(uriTemplate.expand('{/var,undef}', params), '/value'); | ||
assert.same(uriTemplate.expand('{/var,x}/here', params), '/value/1024/here'); | ||
assert.same(uriTemplate.expand('{/var:1,var}', params), '/v/value'); | ||
assert.same(uriTemplate.expand('{/list}', params), '/red,green,blue'); | ||
assert.same(uriTemplate.expand('{/list*}', params), '/red/green/blue'); | ||
assert.same(uriTemplate.expand('{/list*,path:4}', params), '/red/green/blue/%2Ffoo'); | ||
assert.same(uriTemplate.expand('{/keys}', params), '/semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{/keys*}', params), '/semi=%3B/dot=./comma=%2C'); | ||
}, | ||
'3.2.7. Path-Style Parameter Expansion: {;var}': function () { | ||
assert.same(uriTemplate.expand('{;who}', params), ';who=fred'); | ||
assert.same(uriTemplate.expand('{;half}', params), ';half=50%25'); | ||
assert.same(uriTemplate.expand('{;empty}', params), ';empty'); | ||
assert.same(uriTemplate.expand('{;v,empty,who}', params), ';v=6;empty;who=fred'); | ||
assert.same(uriTemplate.expand('{;v,bar,who}', params), ';v=6;who=fred'); | ||
assert.same(uriTemplate.expand('{;x,y}', params), ';x=1024;y=768'); | ||
assert.same(uriTemplate.expand('{;x,y,empty}', params), ';x=1024;y=768;empty'); | ||
assert.same(uriTemplate.expand('{;x,y,undef}', params), ';x=1024;y=768'); | ||
assert.same(uriTemplate.expand('{;hello:5}', params), ';hello=Hello'); | ||
assert.same(uriTemplate.expand('{;list}', params), ';list=red,green,blue'); | ||
assert.same(uriTemplate.expand('{;list*}', params), ';list=red;list=green;list=blue'); | ||
assert.same(uriTemplate.expand('{;keys}', params), ';keys=semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{;keys*}', params), ';semi=%3B;dot=.;comma=%2C'); | ||
}, | ||
'3.2.8. Form-Style Query Expansion: {?var}': function () { | ||
assert.same(uriTemplate.expand('{?who}', params), '?who=fred'); | ||
assert.same(uriTemplate.expand('{?half}', params), '?half=50%25'); | ||
assert.same(uriTemplate.expand('{?x,y}', params), '?x=1024&y=768'); | ||
assert.same(uriTemplate.expand('{?x,y,empty}', params), '?x=1024&y=768&empty='); | ||
assert.same(uriTemplate.expand('{?x,y,undef}', params), '?x=1024&y=768'); | ||
assert.same(uriTemplate.expand('{?var:3}', params), '?var=val'); | ||
assert.same(uriTemplate.expand('{?list}', params), '?list=red,green,blue'); | ||
assert.same(uriTemplate.expand('{?list*}', params), '?list=red&list=green&list=blue'); | ||
assert.same(uriTemplate.expand('{?keys}', params), '?keys=semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{?keys*}', params), '?semi=%3B&dot=.&comma=%2C'); | ||
}, | ||
'3.2.9. Form-Style Query Continuation: {&var}': function () { | ||
assert.same(uriTemplate.expand('{&who}', params), '&who=fred'); | ||
assert.same(uriTemplate.expand('{&half}', params), '&half=50%25'); | ||
assert.same(uriTemplate.expand('?fixed=yes{&x}', params), '?fixed=yes&x=1024'); | ||
assert.same(uriTemplate.expand('{&x,y,empty}', params), '&x=1024&y=768&empty='); | ||
assert.same(uriTemplate.expand('{&x,y,undef}', params), '&x=1024&y=768'); | ||
assert.same(uriTemplate.expand('{&var:3}', params), '&var=val'); | ||
assert.same(uriTemplate.expand('{&list}', params), '&list=red,green,blue'); | ||
assert.same(uriTemplate.expand('{&list*}', params), '&list=red&list=green&list=blue'); | ||
assert.same(uriTemplate.expand('{&keys}', params), '&keys=semi,%3B,dot,.,comma,%2C'); | ||
assert.same(uriTemplate.expand('{&keys*}', params), '&semi=%3B&dot=.&comma=%2C'); | ||
'should support boolean params': function () { | ||
assert.same(uriTemplate.expand('http://example.com/{a}', { a: true }), 'http://example.com/true'); | ||
} | ||
@@ -183,0 +192,0 @@ }); |
@@ -37,4 +37,4 @@ /* | ||
return Object.keys(strings).reduce(function (charMap, set) { | ||
charMap[set] = strings[set].split('').reduce(function (chars, char) { | ||
chars[char] = true; | ||
charMap[set] = strings[set].split('').reduce(function (chars, myChar) { | ||
chars[myChar] = true; | ||
return chars; | ||
@@ -50,7 +50,7 @@ }, {}); | ||
} | ||
return str.split('').map(function (char) { | ||
if (allowed.hasOwnProperty(char)) { | ||
return char; | ||
return str.split('').map(function (myChar) { | ||
if (allowed.hasOwnProperty(myChar)) { | ||
return myChar; | ||
} | ||
var code = char.charCodeAt(0); | ||
var code = myChar.charCodeAt(0); | ||
if (code <= 127) { | ||
@@ -60,3 +60,3 @@ return '%' + code.toString(16).toUpperCase(); | ||
else { | ||
return encodeURIComponent(char).toUpperCase(); | ||
return encodeURIComponent(myChar).toUpperCase(); | ||
} | ||
@@ -63,0 +63,0 @@ }).join(''); |
@@ -58,14 +58,3 @@ /* | ||
} | ||
if (typeof value === 'string') { | ||
if (opts.maxLength) { | ||
value = value.slice(0, opts.maxLength); | ||
} | ||
result += result.length ? operation.separator : operation.first; | ||
if (operation.named) { | ||
result += operation.encoder(variable); | ||
result += value.length ? '=' : operation.empty; | ||
} | ||
result += operation.encoder(value); | ||
} | ||
else if (Array.isArray(value)) { | ||
if (Array.isArray(value)) { | ||
result += value.reduce(function (result, value) { | ||
@@ -90,3 +79,3 @@ if (result.length) { | ||
} | ||
else { | ||
else if (typeof value === 'object') { | ||
result += Object.keys(value).reduce(function (result, name) { | ||
@@ -109,2 +98,14 @@ if (result.length) { | ||
} | ||
else { | ||
value = String(value); | ||
if (opts.maxLength) { | ||
value = value.slice(0, opts.maxLength); | ||
} | ||
result += result.length ? operation.separator : operation.first; | ||
if (operation.named) { | ||
result += operation.encoder(variable); | ||
result += value.length ? '=' : operation.empty; | ||
} | ||
result += operation.encoder(value); | ||
} | ||
@@ -111,0 +112,0 @@ return result; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
442410
9418
368