Skip to content
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 opened this issue Oct 29, 2014 · 9 comments
Closed

ngRoute interpolate route with optional parameters #9819

urffin opened this issue Oct 29, 2014 · 9 comments

Comments

@urffin
Copy link

urffin commented Oct 29, 2014

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 '?/' !!!
@gkalpak
Copy link
Member

gkalpak commented Oct 29, 2014

Can't reproduce on 1.3.0 (fiddle).
The docs seem quite outdated though :(

@urffin
Copy link
Author

urffin commented Oct 29, 2014

i little update your fiddle
see value when set all optional params
like this #/param1/param2/param3/

@gkalpak
Copy link
Member

gkalpak commented Oct 29, 2014

I see. So the trailing / messes optional params.
This seems like a valid bug.

@pkozlowski-opensource pkozlowski-opensource added this to the Backlog milestone Oct 29, 2014
gkalpak added a commit to gkalpak/angular.js that referenced this issue Oct 29, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
@gkalpak
Copy link
Member

gkalpak commented Oct 29, 2014

@Narretz
Copy link
Contributor

Narretz commented Oct 29, 2014

Duplicate of #9742?

@gkalpak
Copy link
Member

gkalpak commented Oct 29, 2014

Uh oh ! There seems to be a whole "ecosystem" (of issues and PRs) around this bug.

I guess I know the drill (#9788) 😃

@Narretz
Copy link
Contributor

Narretz commented Oct 29, 2014

I think it's not that bad ;)

gkalpak added a commit to gkalpak/angular.js that referenced this issue Oct 31, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
@gkalpak
Copy link
Member

gkalpak commented Oct 31, 2014

Indeed, it wasn't that bad 😃


Issues:

(All three PRs mentioned below, address these issues.)


PRs:


My suggestion:

  1. Merge the test-name fixes and the test case from fix($route): fix redirection with optional/eager params #9827.
  2. Merge improve interpolation of params in ngRoute #8200.
  3. Close the PRs: fix(ngRoute): wrong redirect to paths containing optional or special parameters #5746, improve interpolation of params in ngRoute #8200, fix($route): fix redirection with optional/eager params #9827
  4. Close the issues: $routeProvider - optional named group + trailing slash  #9742, ngRoute interpolate route with optional parameters #9819
(Needless to say, if you decide to keep the test-related changes from #9827, I will update the PR with just those changes.)

@Narretz
Copy link
Contributor

Narretz commented Oct 31, 2014

Thanks again @gkalpak for the detailed summary. Looks like #8200 still needs a little work

gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 2, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 4, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 10, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 11, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 11, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 12, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 13, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 14, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 18, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 19, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
gkalpak added a commit to gkalpak/angular.js that referenced this issue Nov 21, 2014
Previously, when (automatically) redirecting from path that fetured a
trailing slash and optional or "eager" parameters, the resulting path
would (incorrectly) contain the special characters (`?`,`*`) along with
the parameter values.

Closes angular#9819
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants