vue-resource
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -5,3 +5,3 @@ { | ||
"description": "A web request service for Vue.js", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"homepage": "https://github.com/vuejs/vue-resource", | ||
@@ -8,0 +8,0 @@ "license": "MIT", |
/** | ||
* vue-resource v0.1.4 | ||
* vue-resource v0.1.5 | ||
* https://github.com/vuejs/vue-resource | ||
@@ -353,2 +353,7 @@ * Released under the MIT License. | ||
if (_.isPlainObject(options.data) && /^(get|jsonp)$/i.test(options.method)) { | ||
_.extend(options.params, options.data); | ||
options.data = ''; | ||
} | ||
promise = (options.method.toLowerCase() == 'jsonp' ? jsonp : xhr).call(this, this.$url || Vue.url, options); | ||
@@ -408,5 +413,5 @@ | ||
if (options.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(options.method)) { | ||
if (options.emulateHTTP && /^(put|patch|delete)$/i.test(options.method)) { | ||
options.headers['X-HTTP-Method-Override'] = options.method; | ||
options.method = 'POST'; | ||
options.method = 'post'; | ||
} | ||
@@ -465,3 +470,2 @@ | ||
_.extend(options.params, options.data); | ||
options.params[options.jsonp] = callback; | ||
@@ -521,3 +525,3 @@ | ||
Http.options = { | ||
method: 'GET', | ||
method: 'get', | ||
params: {}, | ||
@@ -524,0 +528,0 @@ data: '', |
/** | ||
* vue-resource v0.1.4 | ||
* vue-resource v0.1.5 | ||
* https://github.com/vuejs/vue-resource | ||
@@ -7,2 +7,2 @@ * Released under the MIT License. | ||
!function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){function r(e){e.url=n(1)(e),e.http=n(3)(e),e.resource=n(5)(e)}window.Vue&&Vue.use(r),e.exports=r},function(e,t,n){e.exports=function(e){function t(e,n){var r,s={},i={},c=e;return a.isPlainObject(c)||(c={url:e,params:n}),c=a.extend({},t.options,a.options("url",this,c)),e=c.url.replace(/:([a-z]\w*)/gi,function(e,t){return c.params[t]?(s[t]=!0,o(c.params[t])):""}),c.root===!1||e.match(/^(https?:)?\//)||(e=c.root+"/"+e),e=e.replace(/([^:])[\/]{2,}/g,"$1/"),e=e.replace(/(\w+)\/+$/,"$1"),a.each(c.params,function(e,t){s[t]||(i[t]=e)}),r=t.params(i),r&&(e+=(-1==e.indexOf("?")?"?":"&")+r),e}function r(e,t,n){var o,s=a.isArray(t),i=a.isPlainObject(t);a.each(t,function(t,c){o=a.isObject(t)||a.isArray(t),n&&(c=n+"["+(i||o?c:"")+"]"),!n&&s?e.add(t.name,t.value):o?r(e,t,c):e.add(c,t)})}function o(e){return s(e,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function s(e,t){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,t?"%20":"+")}var a=n(2)(e);return t.options={url:"",root:!1,params:{}},t.params=function(e){var t=[];return t.add=function(e,t){a.isFunction(t)&&(t=t()),null===t&&(t=""),this.push(o(e)+"="+o(t))},r(t,e),t.join("&")},t.parse=function(e){var t=new RegExp("^(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?"),n=e.match(t);return{url:e,scheme:n[1]||"",host:n[2]||"",path:n[3]||"",query:n[4]||"",fragment:n[5]||""}},Object.defineProperty(e.prototype,"$url",{get:function(){return a.extend(t.bind(this),t)}}),t}},function(e,t){e.exports=function(e){function t(e,r,o){for(var s in r)o&&(n.isPlainObject(r[s])||n.isArray(r[s]))?(n.isPlainObject(r[s])&&!n.isPlainObject(e[s])&&(e[s]={}),n.isArray(r[s])&&!n.isArray(e[s])&&(e[s]=[]),t(e[s],r[s],o)):void 0!==r[s]&&(e[s]=r[s])}var n=e.util.extend({},e.util);return n.options=function(e,t,r){var o=t.$options||{};return n.extend({},o[e],r)},n.each=function(e,t){var r,o;if("number"==typeof e.length)for(r=0;r<e.length;r++)t.call(e[r],e[r],r);else if(n.isObject(e))for(o in e)e.hasOwnProperty(o)&&t.call(e[o],e[o],o);return e},n.extend=function(e){var n,r=[],o=r.slice.call(arguments,1);return"boolean"==typeof e&&(n=e,e=o.shift()),o.forEach(function(r){t(e,r,n)}),e},n.isFunction=function(e){return e&&"function"==typeof e},n}},function(e,t,n){e.exports=function(e){function t(n,i){var c,u,p=this;return i=i||{},a.isPlainObject(n)&&(i=n,n=""),c=a.extend({},t.headers.common,t.headers[i.method.toLowerCase()]),i=a.extend(!0,{url:n,headers:c},t.options,a.options("http",this,i)),u=("jsonp"==i.method.toLowerCase()?o:r).call(this,this.$url||e.url,i),a.extend(u,{success:function(e){return this.then(function(t){e.apply(p,s(t))},function(){}),this},error:function(e){return this["catch"](function(t){e.apply(p,s(t))}),this},always:function(e){var t=function(t){e.apply(p,s(t))};return this.then(t,t),this}}),i.success&&u.success(i.success),i.error&&u.error(i.error),u}function r(e,t){var n=new XMLHttpRequest;a.isFunction(t.beforeSend)&&t.beforeSend(n,t),t.emulateHTTP&&/^(PUT|PATCH|DELETE)$/i.test(t.method)&&(t.headers["X-HTTP-Method-Override"]=t.method,t.method="POST"),t.emulateJSON&&a.isPlainObject(t.data)&&(t.headers["Content-Type"]="application/x-www-form-urlencoded",t.data=e.params(t.data)),a.isObject(t.data)&&/FormData/i.test(t.data.toString())&&delete t.headers["Content-Type"],a.isPlainObject(t.data)&&(t.data=JSON.stringify(t.data));var r=new i(function(r,o){n.open(t.method,e(t),!0),a.each(t.headers,function(e,t){n.setRequestHeader(t,e)}),n.onreadystatechange=function(){4===this.readyState&&(this.status>=200&&this.status<300?r(this):o(this))},n.send(t.data)});return a.extend(r,{abort:function(){n.abort()}}),r}function o(e,t){var n,r,o="_jsonp"+Math.random().toString(36).substr(2);a.extend(t.params,t.data),t.params[t.jsonp]=o,a.isFunction(t.beforeSend)&&t.beforeSend({},t);var s=new i(function(s,a){n=document.createElement("script"),n.src=e(t.url,t.params),n.type="text/javascript",n.async=!0,window[o]=function(e){r=e};var i=function(e){delete window[o],document.body.removeChild(n),"load"!==e.type||r||(e.type="error");var t=r?r:e.type,i="error"===e.type?404:200;(200===i?s:a)({responseText:t,status:i})};n.onload=i,n.onerror=i,document.body.appendChild(n)});return s}function s(e){var t;try{t=JSON.parse(e.responseText)}catch(n){t=e.responseText}return[t,e.status,e]}var a=n(2)(e),i=n(4),c={"Content-Type":"application/json;charset=utf-8"};return t.options={method:"GET",params:{},data:"",jsonp:"callback",beforeSend:null,emulateHTTP:!1,emulateJSON:!1},t.headers={put:c,post:c,patch:c,"delete":c,common:{Accept:"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest"}},["get","put","post","patch","delete","jsonp"].forEach(function(e){t[e]=function(t,n,r,o){return a.isFunction(n)&&(o=r,r=n,n=void 0),this(t,a.extend({method:e,data:n,success:r},o))}}),Object.defineProperty(e.prototype,"$http",{get:function(){return a.extend(t.bind(this),t)}}),t}},function(e,t){function n(e){e(this.resolve.bind(this),this.reject.bind(this)),this._thens=[]}n.prototype={then:function(e,t,n){this._thens.push({resolve:e,reject:t,progress:n})},"catch":function(e){this._thens.push({reject:e})},resolve:function(e){this._complete("resolve",e)},reject:function(e){this._complete("reject",e)},progress:function(e){for(var t,n=0;t=this._thens[n++];)t.progress&&t.progress(e)},_complete:function(e,t){this.then="resolve"===e?function(e,n){e&&e(t)}:function(e,n){n&&n(t)},this.resolve=this.reject=this.progress=function(){throw new Error("Promise already completed.")};for(var n,r=0;n=this._thens[r++];)n[e]&&n[e](t);delete this._thens}},e.exports=window.Promise?window.Promise:n},function(e,t,n){e.exports=function(e){function t(n,s,a){var i=this,c={};return a=o.extend({},t.actions,a),o.each(a,function(t,a){t=o.extend(!0,{url:n,params:s||{}},t),c[a]=function(){return(i.$http||e.http)(r(t,arguments))}}),c}function r(e,t){var n,r,s,a=o.extend({},e),i={};switch(t.length){case 4:s=t[3],r=t[2];case 3:case 2:if(!o.isFunction(t[1])){i=t[0],n=t[1],r=t[2];break}if(o.isFunction(t[0])){r=t[0],s=t[1];break}r=t[1],s=t[2];case 1:o.isFunction(t[0])?r=t[0]:/^(POST|PUT|PATCH)$/i.test(a.method)?n=t[0]:i=t[0];break;case 0:break;default:throw"Expected up to 4 arguments [params, data, success, error], got "+t.length+" arguments"}return a.url=e.url,a.data=n,a.params=o.extend({},e.params,i),r&&(a.success=r),s&&(a.error=s),a}var o=n(2)(e);return t.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},remove:{method:"DELETE"},"delete":{method:"DELETE"}},Object.defineProperty(e.prototype,"$resource",{get:function(){return t.bind(this)}}),t}}]); | ||
!function(t){function e(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return t[r].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var n={};return e.m=t,e.c=n,e.p="",e(0)}([function(t,e,n){function r(t){t.url=n(1)(t),t.http=n(3)(t),t.resource=n(5)(t)}window.Vue&&Vue.use(r),t.exports=r},function(t,e,n){t.exports=function(t){function e(t,n){var r,s={},i={},c=t;return a.isPlainObject(c)||(c={url:t,params:n}),c=a.extend({},e.options,a.options("url",this,c)),t=c.url.replace(/:([a-z]\w*)/gi,function(t,e){return c.params[e]?(s[e]=!0,o(c.params[e])):""}),c.root===!1||t.match(/^(https?:)?\//)||(t=c.root+"/"+t),t=t.replace(/([^:])[\/]{2,}/g,"$1/"),t=t.replace(/(\w+)\/+$/,"$1"),a.each(c.params,function(t,e){s[e]||(i[e]=t)}),r=e.params(i),r&&(t+=(-1==t.indexOf("?")?"?":"&")+r),t}function r(t,e,n){var o,s=a.isArray(e),i=a.isPlainObject(e);a.each(e,function(e,c){o=a.isObject(e)||a.isArray(e),n&&(c=n+"["+(i||o?c:"")+"]"),!n&&s?t.add(e.name,e.value):o?r(t,e,c):t.add(c,e)})}function o(t){return s(t,!0).replace(/%26/gi,"&").replace(/%3D/gi,"=").replace(/%2B/gi,"+")}function s(t,e){return encodeURIComponent(t).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,e?"%20":"+")}var a=n(2)(t);return e.options={url:"",root:!1,params:{}},e.params=function(t){var e=[];return e.add=function(t,e){a.isFunction(e)&&(e=e()),null===e&&(e=""),this.push(o(t)+"="+o(e))},r(e,t),e.join("&")},e.parse=function(t){var e=new RegExp("^(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\\?([^#]*))?(?:#(.*))?"),n=t.match(e);return{url:t,scheme:n[1]||"",host:n[2]||"",path:n[3]||"",query:n[4]||"",fragment:n[5]||""}},Object.defineProperty(t.prototype,"$url",{get:function(){return a.extend(e.bind(this),e)}}),e}},function(t,e){t.exports=function(t){function e(t,r,o){for(var s in r)o&&(n.isPlainObject(r[s])||n.isArray(r[s]))?(n.isPlainObject(r[s])&&!n.isPlainObject(t[s])&&(t[s]={}),n.isArray(r[s])&&!n.isArray(t[s])&&(t[s]=[]),e(t[s],r[s],o)):void 0!==r[s]&&(t[s]=r[s])}var n=t.util.extend({},t.util);return n.options=function(t,e,r){var o=e.$options||{};return n.extend({},o[t],r)},n.each=function(t,e){var r,o;if("number"==typeof t.length)for(r=0;r<t.length;r++)e.call(t[r],t[r],r);else if(n.isObject(t))for(o in t)t.hasOwnProperty(o)&&e.call(t[o],t[o],o);return t},n.extend=function(t){var n,r=[],o=r.slice.call(arguments,1);return"boolean"==typeof t&&(n=t,t=o.shift()),o.forEach(function(r){e(t,r,n)}),t},n.isFunction=function(t){return t&&"function"==typeof t},n}},function(t,e,n){t.exports=function(t){function e(n,i){var c,u,p=this;return i=i||{},a.isPlainObject(n)&&(i=n,n=""),c=a.extend({},e.headers.common,e.headers[i.method.toLowerCase()]),i=a.extend(!0,{url:n,headers:c},e.options,a.options("http",this,i)),a.isPlainObject(i.data)&&/^(get|jsonp)$/i.test(i.method)&&(a.extend(i.params,i.data),i.data=""),u=("jsonp"==i.method.toLowerCase()?o:r).call(this,this.$url||t.url,i),a.extend(u,{success:function(t){return this.then(function(e){t.apply(p,s(e))},function(){}),this},error:function(t){return this["catch"](function(e){t.apply(p,s(e))}),this},always:function(t){var e=function(e){t.apply(p,s(e))};return this.then(e,e),this}}),i.success&&u.success(i.success),i.error&&u.error(i.error),u}function r(t,e){var n=new XMLHttpRequest;a.isFunction(e.beforeSend)&&e.beforeSend(n,e),e.emulateHTTP&&/^(put|patch|delete)$/i.test(e.method)&&(e.headers["X-HTTP-Method-Override"]=e.method,e.method="post"),e.emulateJSON&&a.isPlainObject(e.data)&&(e.headers["Content-Type"]="application/x-www-form-urlencoded",e.data=t.params(e.data)),a.isObject(e.data)&&/FormData/i.test(e.data.toString())&&delete e.headers["Content-Type"],a.isPlainObject(e.data)&&(e.data=JSON.stringify(e.data));var r=new i(function(r,o){n.open(e.method,t(e),!0),a.each(e.headers,function(t,e){n.setRequestHeader(e,t)}),n.onreadystatechange=function(){4===this.readyState&&(this.status>=200&&this.status<300?r(this):o(this))},n.send(e.data)});return a.extend(r,{abort:function(){n.abort()}}),r}function o(t,e){var n,r,o="_jsonp"+Math.random().toString(36).substr(2);e.params[e.jsonp]=o,a.isFunction(e.beforeSend)&&e.beforeSend({},e);var s=new i(function(s,a){n=document.createElement("script"),n.src=t(e.url,e.params),n.type="text/javascript",n.async=!0,window[o]=function(t){r=t};var i=function(t){delete window[o],document.body.removeChild(n),"load"!==t.type||r||(t.type="error");var e=r?r:t.type,i="error"===t.type?404:200;(200===i?s:a)({responseText:e,status:i})};n.onload=i,n.onerror=i,document.body.appendChild(n)});return s}function s(t){var e;try{e=JSON.parse(t.responseText)}catch(n){e=t.responseText}return[e,t.status,t]}var a=n(2)(t),i=n(4),c={"Content-Type":"application/json;charset=utf-8"};return e.options={method:"get",params:{},data:"",jsonp:"callback",beforeSend:null,emulateHTTP:!1,emulateJSON:!1},e.headers={put:c,post:c,patch:c,"delete":c,common:{Accept:"application/json, text/plain, */*","X-Requested-With":"XMLHttpRequest"}},["get","put","post","patch","delete","jsonp"].forEach(function(t){e[t]=function(e,n,r,o){return a.isFunction(n)&&(o=r,r=n,n=void 0),this(e,a.extend({method:t,data:n,success:r},o))}}),Object.defineProperty(t.prototype,"$http",{get:function(){return a.extend(e.bind(this),e)}}),e}},function(t,e){function n(t){t(this.resolve.bind(this),this.reject.bind(this)),this._thens=[]}n.prototype={then:function(t,e,n){this._thens.push({resolve:t,reject:e,progress:n})},"catch":function(t){this._thens.push({reject:t})},resolve:function(t){this._complete("resolve",t)},reject:function(t){this._complete("reject",t)},progress:function(t){for(var e,n=0;e=this._thens[n++];)e.progress&&e.progress(t)},_complete:function(t,e){this.then="resolve"===t?function(t,n){t&&t(e)}:function(t,n){n&&n(e)},this.resolve=this.reject=this.progress=function(){throw new Error("Promise already completed.")};for(var n,r=0;n=this._thens[r++];)n[t]&&n[t](e);delete this._thens}},t.exports=window.Promise?window.Promise:n},function(t,e,n){t.exports=function(t){function e(n,s,a){var i=this,c={};return a=o.extend({},e.actions,a),o.each(a,function(e,a){e=o.extend(!0,{url:n,params:s||{}},e),c[a]=function(){return(i.$http||t.http)(r(e,arguments))}}),c}function r(t,e){var n,r,s,a=o.extend({},t),i={};switch(e.length){case 4:s=e[3],r=e[2];case 3:case 2:if(!o.isFunction(e[1])){i=e[0],n=e[1],r=e[2];break}if(o.isFunction(e[0])){r=e[0],s=e[1];break}r=e[1],s=e[2];case 1:o.isFunction(e[0])?r=e[0]:/^(POST|PUT|PATCH)$/i.test(a.method)?n=e[0]:i=e[0];break;case 0:break;default:throw"Expected up to 4 arguments [params, data, success, error], got "+e.length+" arguments"}return a.url=t.url,a.data=n,a.params=o.extend({},t.params,i),r&&(a.success=r),s&&(a.error=s),a}var o=n(2)(t);return e.actions={get:{method:"GET"},save:{method:"POST"},query:{method:"GET"},remove:{method:"DELETE"},"delete":{method:"DELETE"}},Object.defineProperty(t.prototype,"$resource",{get:function(){return e.bind(this)}}),e}}]); |
{ | ||
"name": "vue-resource", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "A web request service for Vue.js", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -31,2 +31,7 @@ module.exports = function (Vue) { | ||
if (_.isPlainObject(options.data) && /^(get|jsonp)$/i.test(options.method)) { | ||
_.extend(options.params, options.data); | ||
options.data = ''; | ||
} | ||
promise = (options.method.toLowerCase() == 'jsonp' ? jsonp : xhr).call(this, this.$url || Vue.url, options); | ||
@@ -86,5 +91,5 @@ | ||
if (options.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(options.method)) { | ||
if (options.emulateHTTP && /^(put|patch|delete)$/i.test(options.method)) { | ||
options.headers['X-HTTP-Method-Override'] = options.method; | ||
options.method = 'POST'; | ||
options.method = 'post'; | ||
} | ||
@@ -143,3 +148,2 @@ | ||
_.extend(options.params, options.data); | ||
options.params[options.jsonp] = callback; | ||
@@ -199,3 +203,3 @@ | ||
Http.options = { | ||
method: 'GET', | ||
method: 'get', | ||
params: {}, | ||
@@ -202,0 +206,0 @@ data: '', |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46010
1062