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

Wrong $resource URL when parameter is int==0 #1212

Closed
bonya opened this issue Jul 31, 2012 · 2 comments
Closed

Wrong $resource URL when parameter is int==0 #1212

bonya opened this issue Jul 31, 2012 · 2 comments

Comments

@bonya
Copy link

bonya commented Jul 31, 2012

If resource.userId === 0

$resource('/users/:userId/', {}, {save: {method: 'POST'}}).$save() 

calls the wrong url '/users' instead of '/users/0' since userId === 0 is treated as false during uri segment encoding.

I believe it should be checked agains 'undefined' and null instead.

Version 1.0.1
File: angular-resource.js (292)
encodedVal = encodeUriSegment(params[urlParam] || self.defaults[urlParam] || "");

benjamine pushed a commit to benjamine/angular.js that referenced this issue Aug 20, 2012
when a param value was 0 (or false) it was ignored and removed from url.
after this fix that only happens if the value is undefined or null.
@benjamine
Copy link
Contributor

I ran into this issue too, I'm sending my fix as pull request

@mhevery mhevery closed this as completed Sep 4, 2012
mhevery pushed a commit that referenced this issue Sep 4, 2012
Close #1212

when a param value was 0 (or false) it was ignored and removed from url.
after this fix that only happens if the value is undefined or null.
mhevery pushed a commit that referenced this issue Sep 5, 2012
Close #1212

when a param value was 0 (or false) it was ignored and removed from url.
after this fix that only happens if the value is undefined or null.
mhevery pushed a commit that referenced this issue Sep 6, 2012
Close #1212

when a param value was 0 (or false) it was ignored and removed from url.
after this fix that only happens if the value is undefined or null.
mhevery pushed a commit that referenced this issue Sep 6, 2012
Close #1212

when a param value was 0 (or false) it was ignored and removed from url.
after this fix that only happens if the value is undefined or null.
mhevery pushed a commit to mhevery/angular.js that referenced this issue Sep 7, 2012
Close angular#1212

when a param value was 0 (or false) it was ignored and removed from url.
after this fix that only happens if the value is undefined or null.
@jakecar
Copy link

jakecar commented Oct 29, 2012

There was either a regression, or this issue was not fixed for parameters within the URL string.

http://jsfiddle.net/7XyKh/27/

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

No branches or pull requests

4 participants