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

Multiple optional Parameters #114

Open
TobiasOetzel opened this issue Oct 8, 2014 · 1 comment
Open

Multiple optional Parameters #114

TobiasOetzel opened this issue Oct 8, 2014 · 1 comment

Comments

@TobiasOetzel
Copy link

Hi,

if you define a pattern with 3 optional parameters and you supply the 1st and the 3rd the order is mixed up.
eg : /:lorem:/:ipsum:/:dolor:
matched against /lorem//dolor
will map lorem to lorem,
ipsum to dolor
and dolor to undefined.

i would expect ipsum to be undefined and dolor to be dolor.
Although using a :?parameter: would make more sense if you have 3 optional ones.

i wrote a test in the lexer.spec.js that fails:

    it('should return optional pattern params', function(){
        var pattern = '/:lorem:/:ipsum:/:dolor:',
            regex = crossroads.patternLexer.compilePattern(pattern),
            params = crossroads.patternLexer.getParamValues('/lorem//dolor', regex);

        expect( params[0] ).toEqual( 'lorem' );
        expect( params[1] ).toEqual( undefined );
        expect( params[2] ).toEqual( 'dolor' );
    });

but i did not come up with a fix yet.

Best regards,
Tobias

@corintho
Copy link

Not sure how this is going to be handled here, but on every other routing framework I've seen out there, any optional path parameters were only allowed in the end of the URL.

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

No branches or pull requests

3 participants