Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explode values after non-explodes #19

Open
sebilasse opened this issue Nov 1, 2015 · 3 comments
Open

Explode values after non-explodes #19

sebilasse opened this issue Nov 1, 2015 · 3 comments

Comments

@sebilasse
Copy link
Contributor

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...

@sebilasse
Copy link
Contributor Author

@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;
}

@Ricky-N
Copy link

Ricky-N commented Feb 23, 2018

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.

@Ricky-N
Copy link

Ricky-N commented Feb 23, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants