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.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
steffans committed Sep 9, 2016
2 parents 6dc41c4 + 1807943 commit 4cb829a
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 109 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# vue-resource [![Downloads](https://img.shields.io/npm/dt/vue-resource.svg)](https://www.npmjs.com/package/vue-resource) [![Version](https://img.shields.io/npm/v/vue-resource.svg)](https://www.npmjs.com/package/vue-resource) [![License](https://img.shields.io/npm/l/vue-resource.svg)](https://www.npmjs.com/package/vue-resource)
# vue-resource [![Version](https://img.shields.io/npm/v/vue-resource.svg)](https://www.npmjs.com/package/vue-resource) [![License](https://img.shields.io/npm/l/vue-resource.svg)](https://www.npmjs.com/package/vue-resource) [![Downloads](https://img.shields.io/npm/dt/vue-resource.svg)](https://www.npmjs.com/package/vue-resource)

The plugin for [Vue.js](http://vuejs.org) provides services for making web requests and handle responses using a [XMLHttpRequest](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) or JSONP.

Expand All @@ -22,9 +22,9 @@ $ bower install vue-resource
```

### CDN
Available on [jsdelivr](https://cdn.jsdelivr.net/vue.resource/1.0.0/vue-resource.min.js), [cdnjs](https://cdnjs.com/libraries/vue-resource) or [npmcdn](https://npmcdn.com/[email protected].0/dist/vue-resource.min.js).
Available on [jsdelivr](https://cdn.jsdelivr.net/vue.resource/1.0.1/vue-resource.min.js), [cdnjs](https://cdnjs.com/libraries/vue-resource) or [npmcdn](https://npmcdn.com/[email protected].1/dist/vue-resource.min.js).
```html
<script src="https://cdn.jsdelivr.net/vue.resource/1.0.0/vue-resource.min.js"></script>
<script src="https://cdn.jsdelivr.net/vue.resource/1.0.1/vue-resource.min.js"></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.0.0",
"version": "1.0.1",
"description": "The HTTP client for Vue.js",
"homepage": "https://github.com/vuejs/vue-resource",
"license": "MIT",
Expand Down
56 changes: 31 additions & 25 deletions dist/vue-resource.common.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-resource v1.0.0
* vue-resource v1.0.1
* https://github.com/vuejs/vue-resource
* Released under the MIT License.
*/
Expand Down Expand Up @@ -654,17 +654,17 @@ function crossOrigin(request) {

function body (request, next) {

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

if (isFormData(request.body)) {

request.headers.delete('Content-Type');
}
} else if (isObject(request.body) || isArray(request.body)) {

if (isPlainObject(request.body)) {
request.body = JSON.stringify(request.body);
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);
}
}

next(function (response) {
Expand Down Expand Up @@ -858,11 +858,6 @@ function xhrClient (request) {
return xhr.abort();
};

xhr.open(request.method, request.getUrl(), true);
xhr.timeout = 0;
xhr.onload = handler;
xhr.onerror = handler;

if (request.progress) {
if (request.method === 'GET') {
xhr.addEventListener('progress', request.progress);
Expand All @@ -871,6 +866,8 @@ function xhrClient (request) {
}
}

xhr.open(request.method, request.getUrl(), true);

if ('responseType' in xhr) {
xhr.responseType = 'blob';
}
Expand All @@ -883,6 +880,9 @@ function xhrClient (request) {
xhr.setRequestHeader(name, value);
});

xhr.timeout = 0;
xhr.onload = handler;
xhr.onerror = handler;
xhr.send(request.getBody());
});
}
Expand Down Expand Up @@ -980,37 +980,37 @@ var Headers = function () {
}

Headers.prototype.has = function has(name) {
return this.map.hasOwnProperty(normalizeName(name));
return getName(this.map, name) !== null;
};

Headers.prototype.get = function get(name) {

var list = this.map[normalizeName(name)];
var list = this.map[getName(this.map, name)];

return list ? list[0] : null;
};

Headers.prototype.getAll = function getAll(name) {
return this.map[normalizeName(name)] || [];
return this.map[getName(this.map, name)] || [];
};

Headers.prototype.set = function set(name, value) {
this.map[normalizeName(name)] = [trim(value)];
this.map[normalizeName(getName(this.map, name) || name)] = [trim(value)];
};

Headers.prototype.append = function append(name, value) {

var list = this.map[normalizeName(name)];
var list = this.getAll(name);

if (!list) {
list = this.map[normalizeName(name)] = [];
if (list.length) {
list.push(trim(value));
} else {
this.set(name, value);
}

list.push(trim(value));
};

Headers.prototype.delete = function _delete(name) {
delete this.map[normalizeName(name)];
delete this.map[getName(name)];
};

Headers.prototype.forEach = function forEach(callback, thisArg) {
Expand All @@ -1026,13 +1026,19 @@ var Headers = function () {
return Headers;
}();

function getName(map, name) {
return Object.keys(map).reduce(function (prev, curr) {
return toLower(name) === toLower(curr) ? curr : prev;
}, null);
}

function normalizeName(name) {

if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
throw new TypeError('Invalid character in header field name');
}

return toLower(trim(name));
return trim(name);
}

/**
Expand Down
56 changes: 31 additions & 25 deletions dist/vue-resource.es2015.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* vue-resource v1.0.0
* vue-resource v1.0.1
* https://github.com/vuejs/vue-resource
* Released under the MIT License.
*/
Expand Down Expand Up @@ -652,17 +652,17 @@ function crossOrigin(request) {

function body (request, next) {

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

if (isFormData(request.body)) {

request.headers.delete('Content-Type');
}
} else if (isObject(request.body) || isArray(request.body)) {

if (isPlainObject(request.body)) {
request.body = JSON.stringify(request.body);
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);
}
}

next(function (response) {
Expand Down Expand Up @@ -856,11 +856,6 @@ function xhrClient (request) {
return xhr.abort();
};

xhr.open(request.method, request.getUrl(), true);
xhr.timeout = 0;
xhr.onload = handler;
xhr.onerror = handler;

if (request.progress) {
if (request.method === 'GET') {
xhr.addEventListener('progress', request.progress);
Expand All @@ -869,6 +864,8 @@ function xhrClient (request) {
}
}

xhr.open(request.method, request.getUrl(), true);

if ('responseType' in xhr) {
xhr.responseType = 'blob';
}
Expand All @@ -881,6 +878,9 @@ function xhrClient (request) {
xhr.setRequestHeader(name, value);
});

xhr.timeout = 0;
xhr.onload = handler;
xhr.onerror = handler;
xhr.send(request.getBody());
});
}
Expand Down Expand Up @@ -978,37 +978,37 @@ var Headers = function () {
}

Headers.prototype.has = function has(name) {
return this.map.hasOwnProperty(normalizeName(name));
return getName(this.map, name) !== null;
};

Headers.prototype.get = function get(name) {

var list = this.map[normalizeName(name)];
var list = this.map[getName(this.map, name)];

return list ? list[0] : null;
};

Headers.prototype.getAll = function getAll(name) {
return this.map[normalizeName(name)] || [];
return this.map[getName(this.map, name)] || [];
};

Headers.prototype.set = function set(name, value) {
this.map[normalizeName(name)] = [trim(value)];
this.map[normalizeName(getName(this.map, name) || name)] = [trim(value)];
};

Headers.prototype.append = function append(name, value) {

var list = this.map[normalizeName(name)];
var list = this.getAll(name);

if (!list) {
list = this.map[normalizeName(name)] = [];
if (list.length) {
list.push(trim(value));
} else {
this.set(name, value);
}

list.push(trim(value));
};

Headers.prototype.delete = function _delete(name) {
delete this.map[normalizeName(name)];
delete this.map[getName(name)];
};

Headers.prototype.forEach = function forEach(callback, thisArg) {
Expand All @@ -1024,13 +1024,19 @@ var Headers = function () {
return Headers;
}();

function getName(map, name) {
return Object.keys(map).reduce(function (prev, curr) {
return toLower(name) === toLower(curr) ? curr : prev;
}, null);
}

function normalizeName(name) {

if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) {
throw new TypeError('Invalid character in header field name');
}

return toLower(trim(name));
return trim(name);
}

/**
Expand Down
Loading

0 comments on commit 4cb829a

Please sign in to comment.