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.3.2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffan committed May 22, 2017
2 parents a8e5ba1 + 9d98dfc commit 0da6829
Show file tree
Hide file tree
Showing 18 changed files with 640 additions and 475 deletions.
20 changes: 20 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: 2
jobs:
build:
docker:
- image: node:7.9.0
working_directory: ~/vue-resource
steps:
- run:
name: Update Environment
command: apt-get update && apt-get -y install unzip
- checkout
- run:
name: Install Dependencies
command: yarn
- run:
name: Run Tests
command: yarn test
- run:
name: Build Release
command: yarn run build
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,20 @@ The plugin for [Vue.js](http://vuejs.org) provides services for making web reque
- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API and [URI Templates](https://medialize.github.io/URI.js/uri-template.html)
- Supports [interceptors](docs/http.md#interceptors) for request and response
- Supports latest Firefox, Chrome, Safari, Opera and IE9+
- Supports Vue 1.0 & Vue 2.0
- Compact size 14KB (5.3KB gzipped)

## Installation

### NPM
You can install it via [yarn](https://yarnpkg.com/) or [NPM](http://npmjs.org/).
```
$ yarn add vue-resource
$ npm install vue-resource
```

### Bower
```
$ bower install vue-resource
```

### CDN
Available on [jsdelivr](https://cdn.jsdelivr.net/vue.resource/1.3.1/vue-resource.min.js), [cdnjs](https://cdnjs.com/libraries/vue-resource) or [unpkg](https://unpkg.com/[email protected].1/dist/vue-resource.min.js).
Available on [jsdelivr](https://cdn.jsdelivr.net/vue.resource/1.3.2/vue-resource.min.js), [cdnjs](https://cdnjs.com/libraries/vue-resource) or [unpkg](https://unpkg.com/[email protected].2/dist/vue-resource.min.js).
```html
<script src="https://cdn.jsdelivr.net/vue.resource/1.3.1/vue-resource.min.js"></script>
<script src="https://cdn.jsdelivr.net/vue.resource/1.3.2/vue-resource.min.js"></script>
```

## Example
Expand Down Expand Up @@ -52,11 +48,11 @@ Available on [jsdelivr](https://cdn.jsdelivr.net/vue.resource/1.3.1/vue-resource

## Changelog

Details changes for each release are documented in the [release notes](https://github.com/vuejs/vue-resource/releases).
Details changes for each release are documented in the [release notes](https://github.com/pagekit/vue-resource/releases).

## Contribution

If you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/vuejs/vue-resource/issues) or a [pull request](https://github.com/vuejs/vue-resource/pulls).
If you find a bug or want to contribute to the code or documentation, you can help by submitting an [issue](https://github.com/pagekit/vue-resource/issues) or a [pull request](https://github.com/pagekit/vue-resource/pulls).

## License

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.1",
"version": "1.3.2",
"description": "The HTTP client for Vue.js",
"homepage": "https://github.com/pagekit/vue-resource",
"license": "MIT",
Expand Down
76 changes: 50 additions & 26 deletions dist/vue-resource.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-resource v1.3.1
* vue-resource v1.3.2
* https://github.com/pagekit/vue-resource
* Released under the MIT License.
*/
Expand Down Expand Up @@ -300,6 +300,19 @@ function trim(str) {
return str ? str.replace(/^\s*|\s*$/g, '') : '';
}

function trimEnd(str, chars) {

if (str && chars === undefined) {
return str.replace(/\s+$/, '');
}

if (!str || !chars) {
return str;
}

return str.replace(new RegExp(("[" + chars + "]+$")), '');
}

function toLower(str) {
return str ? str.toLowerCase() : '';
}
Expand Down Expand Up @@ -442,8 +455,8 @@ var root = function (options$$1, next) {

var url = next(options$$1);

if (isString(options$$1.root) && !url.match(/^(https?:)?\//)) {
url = options$$1.root + '/' + url;
if (isString(options$$1.root) && !/^(https?:)?\//.test(url)) {
url = trimEnd(options$$1.root, '/') + '/' + url;
}

return url;
Expand Down Expand Up @@ -836,42 +849,41 @@ var cors = function (request, next) {
};

/**
* Body Interceptor.
* Form data Interceptor.
*/

var body = function (request, next) {
var form = function (request, next) {

if (isFormData(request.body)) {

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

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

if (request.emulateJSON) {
request.body = Url.params(request.body);
request.headers.set('Content-Type', 'application/x-www-form-urlencoded');
} else {
request.body = JSON.stringify(request.body);
}
request.body = Url.params(request.body);
request.headers.set('Content-Type', 'application/x-www-form-urlencoded');
}

next(function (response) {
next();
};

/**
* JSON Interceptor.
*/

Object.defineProperty(response, 'data', {
var json = function (request, next) {

get: function get() {
return this.body;
},
var type = request.headers.get('Content-Type') || '';

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

});
next(function (response) {

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

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

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

Expand Down Expand Up @@ -1299,6 +1311,18 @@ Response.prototype.json = function json () {
return when(this.text(), function (text) { return JSON.parse(text); });
};

Object.defineProperty(Response.prototype, 'data', {

get: function get() {
return this.body;
},

set: function set(body) {
this.body = body;
}

});

function blobText(body) {
return new PromiseObj(function (resolve) {

Expand Down Expand Up @@ -1396,8 +1420,8 @@ Http.headers = {
custom: {}
};

Http.interceptor = {before: before, method: method, body: body, jsonp: jsonp, header: header, cors: cors};
Http.interceptors = ['before', 'method', 'body', 'jsonp', 'header', 'cors'];
Http.interceptor = {before: before, method: method, jsonp: jsonp, json: json, form: form, header: header, cors: cors};
Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors'];

['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) {

Expand All @@ -1409,8 +1433,8 @@ Http.interceptors = ['before', 'method', 'body', 'jsonp', 'header', 'cors'];

['post', 'put', 'patch'].forEach(function (method$$1) {

Http[method$$1] = function (url, body$$1, options$$1) {
return this(assign(options$$1 || {}, {url: url, method: method$$1, body: body$$1}));
Http[method$$1] = function (url, body, options$$1) {
return this(assign(options$$1 || {}, {url: url, method: method$$1, body: body}));
};

});
Expand Down
76 changes: 50 additions & 26 deletions dist/vue-resource.es2015.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-resource v1.3.1
* vue-resource v1.3.2
* https://github.com/pagekit/vue-resource
* Released under the MIT License.
*/
Expand Down Expand Up @@ -298,6 +298,19 @@ function trim(str) {
return str ? str.replace(/^\s*|\s*$/g, '') : '';
}

function trimEnd(str, chars) {

if (str && chars === undefined) {
return str.replace(/\s+$/, '');
}

if (!str || !chars) {
return str;
}

return str.replace(new RegExp(("[" + chars + "]+$")), '');
}

function toLower(str) {
return str ? str.toLowerCase() : '';
}
Expand Down Expand Up @@ -440,8 +453,8 @@ var root = function (options$$1, next) {

var url = next(options$$1);

if (isString(options$$1.root) && !url.match(/^(https?:)?\//)) {
url = options$$1.root + '/' + url;
if (isString(options$$1.root) && !/^(https?:)?\//.test(url)) {
url = trimEnd(options$$1.root, '/') + '/' + url;
}

return url;
Expand Down Expand Up @@ -834,42 +847,41 @@ var cors = function (request, next) {
};

/**
* Body Interceptor.
* Form data Interceptor.
*/

var body = function (request, next) {
var form = function (request, next) {

if (isFormData(request.body)) {

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

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

if (request.emulateJSON) {
request.body = Url.params(request.body);
request.headers.set('Content-Type', 'application/x-www-form-urlencoded');
} else {
request.body = JSON.stringify(request.body);
}
request.body = Url.params(request.body);
request.headers.set('Content-Type', 'application/x-www-form-urlencoded');
}

next(function (response) {
next();
};

/**
* JSON Interceptor.
*/

Object.defineProperty(response, 'data', {
var json = function (request, next) {

get: function get() {
return this.body;
},
var type = request.headers.get('Content-Type') || '';

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

});
next(function (response) {

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

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

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

Expand Down Expand Up @@ -1297,6 +1309,18 @@ Response.prototype.json = function json () {
return when(this.text(), function (text) { return JSON.parse(text); });
};

Object.defineProperty(Response.prototype, 'data', {

get: function get() {
return this.body;
},

set: function set(body) {
this.body = body;
}

});

function blobText(body) {
return new PromiseObj(function (resolve) {

Expand Down Expand Up @@ -1394,8 +1418,8 @@ Http.headers = {
custom: {}
};

Http.interceptor = {before: before, method: method, body: body, jsonp: jsonp, header: header, cors: cors};
Http.interceptors = ['before', 'method', 'body', 'jsonp', 'header', 'cors'];
Http.interceptor = {before: before, method: method, jsonp: jsonp, json: json, form: form, header: header, cors: cors};
Http.interceptors = ['before', 'method', 'jsonp', 'json', 'form', 'header', 'cors'];

['get', 'delete', 'head', 'jsonp'].forEach(function (method$$1) {

Expand All @@ -1407,8 +1431,8 @@ Http.interceptors = ['before', 'method', 'body', 'jsonp', 'header', 'cors'];

['post', 'put', 'patch'].forEach(function (method$$1) {

Http[method$$1] = function (url, body$$1, options$$1) {
return this(assign(options$$1 || {}, {url: url, method: method$$1, body: body$$1}));
Http[method$$1] = function (url, body, options$$1) {
return this(assign(options$$1 || {}, {url: url, method: method$$1, body: body}));
};

});
Expand Down
Loading

0 comments on commit 0da6829

Please sign in to comment.