angular-resource
Advanced tools
Comparing version 1.5.0-beta.0 to 1.5.0-beta.2
/** | ||
* @license AngularJS v1.5.0-beta.0 | ||
* @license AngularJS v1.5.0-beta.2 | ||
* (c) 2010-2015 Google, Inc. http://angularjs.org | ||
@@ -441,3 +441,5 @@ * License: MIT | ||
(new RegExp("(^|[^\\\\]):" + param + "(\\W|$)").test(url))) { | ||
urlParams[param] = true; | ||
urlParams[param] = { | ||
isQueryParamValue: (new RegExp("\\?.*=:" + param + "(?:\\W|$)")).test(url) | ||
}; | ||
} | ||
@@ -452,6 +454,10 @@ }); | ||
params = params || {}; | ||
forEach(self.urlParams, function(_, urlParam) { | ||
forEach(self.urlParams, function(paramInfo, urlParam) { | ||
val = params.hasOwnProperty(urlParam) ? params[urlParam] : self.defaults[urlParam]; | ||
if (angular.isDefined(val) && val !== null) { | ||
encodedVal = encodeUriSegment(val); | ||
if (paramInfo.isQueryParamValue) { | ||
encodedVal = encodeUriQuery(val, true); | ||
} else { | ||
encodedVal = encodeUriSegment(val); | ||
} | ||
url = url.replace(new RegExp(":" + urlParam + "(\\W|$)", "g"), function(match, p1) { | ||
@@ -578,4 +584,13 @@ return encodedVal + p1; | ||
forEach(action, function(value, key) { | ||
if (key != 'params' && key != 'isArray' && key != 'interceptor') { | ||
httpConfig[key] = copy(value); | ||
switch (key) { | ||
default: | ||
httpConfig[key] = copy(value); | ||
break; | ||
case 'params': | ||
case 'isArray': | ||
case 'interceptor': | ||
break; | ||
case 'timeout': | ||
httpConfig[key] = value; | ||
break; | ||
} | ||
@@ -582,0 +597,0 @@ }); |
/* | ||
AngularJS v1.5.0-beta.0 | ||
AngularJS v1.5.0-beta.2 | ||
(c) 2010-2015 Google, Inc. http://angularjs.org | ||
License: MIT | ||
*/ | ||
(function(I,f,C){'use strict';function D(t,e){e=e||{};f.forEach(e,function(f,k){delete e[k]});for(var k in t)!t.hasOwnProperty(k)||"$"===k.charAt(0)&&"$"===k.charAt(1)||(e[k]=t[k]);return e}var y=f.$$minErr("$resource"),B=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;f.module("ngResource",["ng"]).provider("$resource",function(){var t=/^https?:\/\/[^\/]*/,e=this;this.defaults={stripTrailingSlashes:!0,actions:{get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}}}; | ||
this.$get=["$http","$q",function(k,F){function w(f,g){this.template=f;this.defaults=r({},e.defaults,g);this.urlParams={}}function z(l,g,s,h){function c(b,q){var c={};q=r({},g,q);u(q,function(a,q){x(a)&&(a=a());var m;if(a&&a.charAt&&"@"==a.charAt(0)){m=b;var d=a.substr(1);if(null==d||""===d||"hasOwnProperty"===d||!B.test("."+d))throw y("badmember",d);for(var d=d.split("."),n=0,g=d.length;n<g&&f.isDefined(m);n++){var e=d[n];m=null!==m?m[e]:C}}else m=a;c[q]=m});return c}function G(b){return b.resource} | ||
function d(b){D(b||{},this)}var t=new w(l,h);s=r({},e.defaults.actions,s);d.prototype.toJSON=function(){var b=r({},this);delete b.$promise;delete b.$resolved;return b};u(s,function(b,q){var g=/^(POST|PUT|PATCH)$/i.test(b.method);d[q]=function(a,A,m,e){var n={},h,l,s;switch(arguments.length){case 4:s=e,l=m;case 3:case 2:if(x(A)){if(x(a)){l=a;s=A;break}l=A;s=m}else{n=a;h=A;l=m;break}case 1:x(a)?l=a:g?h=a:n=a;break;case 0:break;default:throw y("badargs",arguments.length);}var w=this instanceof d,p=w? | ||
h:b.isArray?[]:new d(h),v={},z=b.interceptor&&b.interceptor.response||G,B=b.interceptor&&b.interceptor.responseError||C;u(b,function(b,a){"params"!=a&&"isArray"!=a&&"interceptor"!=a&&(v[a]=H(b))});g&&(v.data=h);t.setUrlParams(v,r({},c(h,b.params||{}),n),b.url);n=k(v).then(function(a){var c=a.data,m=p.$promise;if(c){if(f.isArray(c)!==!!b.isArray)throw y("badcfg",q,b.isArray?"array":"object",f.isArray(c)?"array":"object",v.method,v.url);b.isArray?(p.length=0,u(c,function(a){"object"===typeof a?p.push(new d(a)): | ||
p.push(a)})):(D(c,p),p.$promise=m)}p.$resolved=!0;a.resource=p;return a},function(a){p.$resolved=!0;(s||E)(a);return F.reject(a)});n=n.then(function(a){var b=z(a);(l||E)(b,a.headers);return b},B);return w?n:(p.$promise=n,p.$resolved=!1,p)};d.prototype["$"+q]=function(a,b,c){x(a)&&(c=b,b=a,a={});a=d[q].call(this,a,this,b,c);return a.$promise||a}});d.bind=function(b){return z(l,r({},g,b),s)};return d}var E=f.noop,u=f.forEach,r=f.extend,H=f.copy,x=f.isFunction;w.prototype={setUrlParams:function(l,g, | ||
e){var h=this,c=e||h.template,k,d,r="",b=h.urlParams={};u(c.split(/\W/),function(d){if("hasOwnProperty"===d)throw y("badname");!/^\d+$/.test(d)&&d&&(new RegExp("(^|[^\\\\]):"+d+"(\\W|$)")).test(c)&&(b[d]=!0)});c=c.replace(/\\:/g,":");c=c.replace(t,function(b){r=b;return""});g=g||{};u(h.urlParams,function(b,e){k=g.hasOwnProperty(e)?g[e]:h.defaults[e];f.isDefined(k)&&null!==k?(d=encodeURIComponent(k).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"%20").replace(/%26/gi, | ||
"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+"),c=c.replace(new RegExp(":"+e+"(\\W|$)","g"),function(a,b){return d+b})):c=c.replace(new RegExp("(/?):"+e+"(\\W|$)","g"),function(a,b,c){return"/"==c.charAt(0)?c:b+c})});h.defaults.stripTrailingSlashes&&(c=c.replace(/\/+$/,"")||"/");c=c.replace(/\/\.(?=\w+($|\?))/,".");l.url=r+c.replace(/\/\\\./,"/.");u(g,function(b,c){h.urlParams[c]||(l.params=l.params||{},l.params[c]=b)})}};return z}]})})(window,window.angular); | ||
(function(J,f,C){'use strict';function D(s,e){e=e||{};f.forEach(e,function(f,g){delete e[g]});for(var g in s)!s.hasOwnProperty(g)||"$"===g.charAt(0)&&"$"===g.charAt(1)||(e[g]=s[g]);return e}var x=f.$$minErr("$resource"),G=/^(\.[a-zA-Z_$@][0-9a-zA-Z_$@]*)+$/;f.module("ngResource",["ng"]).provider("$resource",function(){var s=/^https?:\/\/[^\/]*/,e=this;this.defaults={stripTrailingSlashes:!0,actions:{get:{method:"GET"},save:{method:"POST"},query:{method:"GET",isArray:!0},remove:{method:"DELETE"},"delete":{method:"DELETE"}}}; | ||
this.$get=["$http","$q",function(g,F){function v(f,a){return encodeURIComponent(f).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,a?"%20":"+")}function y(f,a){this.template=f;this.defaults=r({},e.defaults,a);this.urlParams={}}function z(l,a,n,h){function d(c,q){var d={};q=r({},a,q);t(q,function(b,q){w(b)&&(b=b());var p;if(b&&b.charAt&&"@"==b.charAt(0)){p=c;var a=b.substr(1);if(null==a||""===a||"hasOwnProperty"===a||!G.test("."+a))throw x("badmember", | ||
a);for(var a=a.split("."),k=0,e=a.length;k<e&&f.isDefined(p);k++){var g=a[k];p=null!==p?p[g]:C}}else p=b;d[q]=p});return d}function H(c){return c.resource}function k(c){D(c||{},this)}var s=new y(l,h);n=r({},e.defaults.actions,n);k.prototype.toJSON=function(){var c=r({},this);delete c.$promise;delete c.$resolved;return c};t(n,function(c,q){var a=/^(POST|PUT|PATCH)$/i.test(c.method);k[q]=function(b,A,p,e){var h={},l,n,B;switch(arguments.length){case 4:B=e,n=p;case 3:case 2:if(w(A)){if(w(b)){n=b;B=A; | ||
break}n=A;B=p}else{h=b;l=A;n=p;break}case 1:w(b)?n=b:a?l=b:h=b;break;case 0:break;default:throw x("badargs",arguments.length);}var v=this instanceof k,m=v?l:c.isArray?[]:new k(l),u={},y=c.interceptor&&c.interceptor.response||H,z=c.interceptor&&c.interceptor.responseError||C;t(c,function(c,b){switch(b){default:u[b]=I(c);break;case "params":case "isArray":case "interceptor":break;case "timeout":u[b]=c}});a&&(u.data=l);s.setUrlParams(u,r({},d(l,c.params||{}),h),c.url);h=g(u).then(function(b){var a=b.data, | ||
d=m.$promise;if(a){if(f.isArray(a)!==!!c.isArray)throw x("badcfg",q,c.isArray?"array":"object",f.isArray(a)?"array":"object",u.method,u.url);c.isArray?(m.length=0,t(a,function(b){"object"===typeof b?m.push(new k(b)):m.push(b)})):(D(a,m),m.$promise=d)}m.$resolved=!0;b.resource=m;return b},function(b){m.$resolved=!0;(B||E)(b);return F.reject(b)});h=h.then(function(b){var a=y(b);(n||E)(a,b.headers);return a},z);return v?h:(m.$promise=h,m.$resolved=!1,m)};k.prototype["$"+q]=function(b,a,c){w(b)&&(c=a, | ||
a=b,b={});b=k[q].call(this,b,this,a,c);return b.$promise||b}});k.bind=function(c){return z(l,r({},a,c),n)};return k}var E=f.noop,t=f.forEach,r=f.extend,I=f.copy,w=f.isFunction;y.prototype={setUrlParams:function(l,a,e){var h=this,d=e||h.template,g,k,r="",c=h.urlParams={};t(d.split(/\W/),function(a){if("hasOwnProperty"===a)throw x("badname");!/^\d+$/.test(a)&&a&&(new RegExp("(^|[^\\\\]):"+a+"(\\W|$)")).test(d)&&(c[a]={isQueryParamValue:(new RegExp("\\?.*=:"+a+"(?:\\W|$)")).test(d)})});d=d.replace(/\\:/g, | ||
":");d=d.replace(s,function(a){r=a;return""});a=a||{};t(h.urlParams,function(c,e){g=a.hasOwnProperty(e)?a[e]:h.defaults[e];f.isDefined(g)&&null!==g?(k=c.isQueryParamValue?v(g,!0):v(g,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+"),d=d.replace(new RegExp(":"+e+"(\\W|$)","g"),function(a,c){return k+c})):d=d.replace(new RegExp("(/?):"+e+"(\\W|$)","g"),function(a,c,d){return"/"==d.charAt(0)?d:c+d})});h.defaults.stripTrailingSlashes&&(d=d.replace(/\/+$/,"")||"/");d=d.replace(/\/\.(?=\w+($|\?))/, | ||
".");l.url=r+d.replace(/\/\\\./,"/.");t(a,function(a,c){h.urlParams[c]||(l.params=l.params||{},l.params[c]=a)})}};return z}]})})(window,window.angular); | ||
//# sourceMappingURL=angular-resource.min.js.map |
{ | ||
"name": "angular-resource", | ||
"version": "1.5.0-beta.0", | ||
"version": "1.5.0-beta.2", | ||
"main": "./angular-resource.js", | ||
"ignore": [], | ||
"dependencies": { | ||
"angular": "1.5.0-beta.0" | ||
"angular": "1.5.0-beta.2" | ||
} | ||
} |
{ | ||
"name": "angular-resource", | ||
"version": "1.5.0-beta.0", | ||
"version": "1.5.0-beta.2", | ||
"description": "AngularJS module for interacting with RESTful server-side data sources", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
44473
660