Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffan committed Feb 22, 2018
2 parents d0b845a + a694861 commit 9a056da
Show file tree
Hide file tree
Showing 17 changed files with 849 additions and 1,167 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ $ npm install vue-resource
```

### CDN
Available on [jsdelivr](https://cdn.jsdelivr.net/npm/vue-resource@1.3.6), [unpkg](https://unpkg.com/vue-resource@1.3.6) or [cdnjs](https://cdnjs.com/libraries/vue-resource).
Available on [jsdelivr](https://cdn.jsdelivr.net/npm/vue-resource@1.4.0), [unpkg](https://unpkg.com/vue-resource@1.4.0) or [cdnjs](https://cdnjs.com/libraries/vue-resource).
```html
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.3.6"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.4.0"></script>
```

## Example
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "vue-resource",
"main": "dist/vue-resource.js",
"version": "1.3.6",
"version": "1.4.0",
"description": "The HTTP client for Vue.js",
"homepage": "https://github.com/pagekit/vue-resource",
"license": "MIT",
Expand Down
86 changes: 33 additions & 53 deletions dist/vue-resource.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-resource v1.3.6
* vue-resource v1.4.0
* https://github.com/pagekit/vue-resource
* Released under the MIT License.
*/
Expand Down Expand Up @@ -264,11 +264,9 @@ p$1.finally = function (callback) {

var ref = {};
var hasOwnProperty = ref.hasOwnProperty;

var ref$1 = [];
var slice = ref$1.slice;
var debug = false;
var ntick;
var debug = false, ntick;

var inBrowser = typeof window !== 'undefined';

Expand Down Expand Up @@ -327,8 +325,6 @@ function isString(val) {
return typeof val === 'string';
}



function isFunction(val) {
return typeof val === 'function';
}
Expand Down Expand Up @@ -827,7 +823,7 @@ function xdrClient (request) {

var SUPPORTS_CORS = inBrowser && 'withCredentials' in new XMLHttpRequest();

function cors (request, next) {
function cors (request) {

if (inBrowser) {

Expand All @@ -845,45 +841,40 @@ function cors (request, next) {
}
}

next();
}

/**
* Form data Interceptor.
*/

function form (request, next) {
function form (request) {

if (isFormData(request.body)) {

request.headers.delete('Content-Type');

} else if (isObject(request.body) && request.emulateJSON) {

request.body = Url.params(request.body);
request.headers.set('Content-Type', 'application/x-www-form-urlencoded');
}

next();
}

/**
* JSON Interceptor.
*/

function json (request, next) {
function json (request) {

var type = request.headers.get('Content-Type') || '';

if (isObject(request.body) && type.indexOf('application/json') === 0) {
request.body = JSON.stringify(request.body);
}

next(function (response) {
return function (response) {

return response.bodyText ? when(response.text(), function (text) {

type = response.headers.get('Content-Type') || '';
var type = response.headers.get('Content-Type') || '';

if (type.indexOf('application/json') === 0 || isJson(text)) {

Expand All @@ -901,7 +892,7 @@ function json (request, next) {

}) : response;

});
};
}

function isJson(str) {
Expand Down Expand Up @@ -970,47 +961,44 @@ function jsonpClient (request) {
* JSONP Interceptor.
*/

function jsonp (request, next) {
function jsonp (request) {

if (request.method == 'JSONP') {
request.client = jsonpClient;
}

next();
}

/**
* Before Interceptor.
*/

function before (request, next) {
function before (request) {

if (isFunction(request.before)) {
request.before.call(this, request);
}

next();
}

/**
* HTTP method override Interceptor.
*/

function method (request, next) {
function method (request) {

if (request.emulateHTTP && /^(PUT|PATCH|DELETE)$/i.test(request.method)) {
request.headers.set('X-HTTP-Method-Override', request.method);
request.method = 'POST';
}

next();
}

/**
* Header Interceptor.
*/

function header (request, next) {
function header (request) {

var headers = assign({}, Http.headers.common,
!request.crossOrigin ? Http.headers.custom : {},
Expand All @@ -1023,7 +1011,6 @@ function header (request, next) {
}
});

next();
}

/**
Expand Down Expand Up @@ -1130,52 +1117,45 @@ function nodeClient (request) {

function Client (context) {

var reqHandlers = [sendRequest], resHandlers = [], handler;
var reqHandlers = [sendRequest], resHandlers = [];

if (!isObject(context)) {
context = null;
}

function Client(request) {
return new PromiseObj(function (resolve, reject) {

function exec() {
while (reqHandlers.length) {

handler = reqHandlers.pop();
var handler = reqHandlers.pop();

if (isFunction(handler)) {
handler.call(context, request, next);
} else {
warn(("Invalid interceptor of type " + (typeof handler) + ", must be a function"));
next();
}
}
if (isFunction(handler)) {

function next(response) {
var response = (void 0), next = (void 0);

if (isFunction(response)) {
response = handler.call(context, request, function (val) { return next = val; }) || next;

resHandlers.unshift(response);
if (isObject(response)) {
return new PromiseObj(function (resolve, reject) {

} else if (isObject(response)) {
resHandlers.forEach(function (handler) {
response = when(response, function (response) {
return handler.call(context, response) || response;
}, reject);
});

resHandlers.forEach(function (handler) {
response = when(response, function (response) {
return handler.call(context, response) || response;
}, reject);
});
when(response, resolve, reject);

when(response, resolve, reject);
}, context);
}

return;
if (isFunction(response)) {
resHandlers.unshift(response);
}

exec();
} else {
warn(("Invalid interceptor of type " + (typeof handler) + ", must be a function"));
}

exec();

}, context);
}
}

Client.use = function (handler) {
Expand Down
Loading

0 comments on commit 9a056da

Please sign in to comment.