Explode values after non-explodes
Hey Geraint,
given the template {/id}{/foo*}{?rql*}
and the URI 'http://localhost/ab/foo/bar'
de-substitution produces
{ foo: [ 'ab', 'foo', 'bar' ] }
but shouldn't it be
{ id: 'ab', foo: [ 'foo', 'bar' ] }
???
The comma delimited syntax {/id,foo*} works but I think the above should work the same...
@geraintluff I am using this function now to "normalize" an RFC6570 template (which is submitted by users in an ldo, so I don't know what syntax they submit) :
function normalizeLDO(ldo) {
var op = false;
var tpls = ldo.href.split('{');
if (tpls.length > 1) {
var href = ['#',ldo.href].join('');
return href.replace(/\/\{\//g,'{/').split('}{').map(function(p){
var cOp = p.substring(0,1);
if ((cOp === '.' || cOp === '/') && (!op || op === cOp)) {
op = cOp;
return [',',p.substring(1)].join('');
} else {
return (!op) ? p : ['}{',p].join('');
}
}).join('').substring(1);
}
return ldo;
}
I'm also having problems with explodes after a list of non-explode variables. This isn't tested out in uritemplate-test so I'm following up with a PR there, but here's a failing test:
1: Extended examples (de-substitution) Additional Examples 5: Explode Combinations {?id,token,keys*}
"?id=admin&token=12345" === "?id=admin&token=12345&key1=val1&key2=val2"
<no stack>
- ?id=admin&token=12345&key1=val1&key2=val2
|||||||||||||||||||||--------------------
+ ?id=admin&token=12345
I tested the same examples against this other implementation and it passed, but we have a bit of fairly central code that depends on this so I'm not sure whether it is more appropriate to fix here or switch over.
Test case PR is here, but there are several open PRs with no response, so not sure how long that will take to get through.