Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

ngRoute interpolate route with optional parameters #9819

Closed
@urffin

Description

@urffin

if we have route path like
/:lang/:paramone?/:paramtwo?

then interpolate function
for params = { lang:'en', paramone:'one', paramtwo:'two' }
return next wrong url
/en/one?/two?/

because in this code

var segmentMatch = segment.match(/(\w+)(.*)/); //possibly wrong regexp
var key = segmentMatch[1];
result.push(params[key]);
result.push(segmentMatch[2] || '');

for paramone we have:

segment = 'paramone?'
segmentMatch = ["paramone?/", "paramone", "?/"]
key = "paramone"
result.push(segmentMatch[2] || ''); // push '?/' !!!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions