Socket
Socket
Sign inDemoInstall

rest

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rest - npm Package Compare versions

Comparing version 1.3.1 to 1.3.2

test/browsers/android-5.1.json

2

bower.json
{
"name": "rest",
"version": "1.3.1",
"version": "1.3.2",
"main": "./browser.js",

@@ -5,0 +5,0 @@ "moduleType": ["amd", "node"],

@@ -110,3 +110,3 @@ /*

script.async = true;
script.src = new UrlBuilder(request.path, request.params).build(callbackParams);
script.src = response.url = new UrlBuilder(request.path, request.params).build(callbackParams);

@@ -113,0 +113,0 @@ function handlePossibleError() {

@@ -75,3 +75,3 @@ /*

url = new UrlBuilder(request.path || '', request.params).build();
url = response.url = new UrlBuilder(request.path || '', request.params).build();
client = url.match(httpsExp) ? https : http;

@@ -78,0 +78,0 @@

@@ -39,3 +39,3 @@ /*

method = request.method;
url = new UrlBuilder(request.path || '', request.params).build();
url = response.url = new UrlBuilder(request.path || '', request.params).build();

@@ -42,0 +42,0 @@ try {

@@ -86,13 +86,13 @@ /*

entity = request.entity;
request.method = request.method || (entity ? 'POST' : 'GET');
method = request.method;
url = response.url = new UrlBuilder(request.path || '', request.params).build();
XMLHttpRequest = request.engine || global.XMLHttpRequest;
if (!XMLHttpRequest) {
reject({ request: request, error: 'xhr-not-available' });
reject({ request: request, url: url, error: 'xhr-not-available' });
return;
}
entity = request.entity;
request.method = request.method || (entity ? 'POST' : 'GET');
method = request.method;
url = new UrlBuilder(request.path || '', request.params).build();
try {

@@ -99,0 +99,0 @@ client = response.raw = new XMLHttpRequest();

@@ -241,3 +241,3 @@ # Interceptors

// assuming a native ES5 environment
client = rest.warp(mime).wrap(hateoas);
client = rest.wrap(mime).wrap(hateoas);
client({ path: '/people/scott' }).then(function (response) {

@@ -364,3 +364,3 @@ // assuming response for /people/scott: { entity: '{ "name": "Scott", "links": [ { "rel": "father", "href": "/peopele/ron" } ], ... }', ... }

<td>optional</td>
td><em>false</em></td>
<td><em>false</em></td>
<td>allow an unknown mime type for a request</td>

@@ -432,4 +432,6 @@ </tr>

The template interceptor fully defines the request URI by expending the path as a URI Template with the request params. Params defined by the tempalte that are missing as well as additional params are ignored. After the template interceptor, the request.params are removed from the request object, as the URI is fully defined.
The template interceptor fully defines the request URI by expending the path as a URI Template with the request params. Params defined by the template that are missing as well as additional params are ignored. After the template interceptor, the request.params are removed from the request object, as the URI is fully defined.
The [URI Template RFC](https://tools.ietf.org/html/rfc6570) has many good examples that fully demonstrate its power and potential.
Note: primitive templating is provided by `rest/UrlBuilder`, however, its behavior is non-standard and less powerful.

@@ -989,3 +991,3 @@

init: function (config) {
// do studd with the config
// do stuff with the config
return config;

@@ -992,0 +994,0 @@ },

@@ -87,2 +87,6 @@ # Common Interfaces

<tr>
<td>url</td>
<td>the actual URL requested. In some cases this value may be misleading, such as after a redirect in a browser. The value reported is URL for the request before the redirect.</td>
</tr>
<tr>
<td>status.code</td>

@@ -89,0 +93,0 @@ <td>status code of the response (i.e. 200, 404)</td>

@@ -125,3 +125,3 @@ /*

},
response: function (response, config, client) {
response: function (response, config, meta) {
if (response.status.code === 401) {

@@ -131,3 +131,3 @@ // token probably expired, reauthorize

config.token = authorization;
return client(response.request);
return meta.client(response.request);
});

@@ -134,0 +134,0 @@ }

@@ -24,2 +24,4 @@ /*

*
* @see https://tools.ietf.org/html/rfc6570
*
* @param {Client} [client] client to wrap

@@ -26,0 +28,0 @@ * @param {Object} [config.params] default param values

{
"name": "rest",
"version": "1.3.1",
"version": "1.3.2",
"description": "RESTful HTTP client library",
"keywords": ["rest", "http", "client", "rest-template", "spring", "cujojs"],
"licenses": [
{
"type": "MIT",
"url": "http://opensource.org/licenses/MIT"
}
],
"license": "MIT",
"repository": {

@@ -13,0 +8,0 @@ "type": "git",

@@ -83,3 +83,3 @@ rest.js

In this example, we take the client create by the [MIME Interceptor](docs/interceptors.md#module-rest/interceptor/mime), and wrap it with the [Error Code Interceptor](https://github.com/s2js/rest/blob/cujojs/docs/interceptors.md#module-rest/interceptor/errorCode). The error code interceptor accepts a configuration object that indicates what status codes should be considered an error. In this case we override the default value of <=400, to only reject with 500 or greater status code.
In this example, we take the client create by the [MIME Interceptor](docs/interceptors.md#module-rest/interceptor/mime), and wrap it with the [Error Code Interceptor](docs/interceptors.md#module-rest/interceptor/errorCode). The error code interceptor accepts a configuration object that indicates what status codes should be considered an error. In this case we override the default value of <=400, to only reject with 500 or greater status code.

@@ -145,8 +145,9 @@ Since the error code interceptor can reject the response promise, we also add a second handler function to receive the response for requests in error.

Tested environments:
- Node.js (0.6, 0.8. 0.10)
- Node.js (0.6, 0.8. 0.10, 4, 5)
- Chrome (stable)
- Firefox (stable, ESR, should work in earlier versions)
- Edge
- IE (6-11)
- Safari (5-8, iOS 4-8.1, should work in earlier versions)
- Android (4.0-5.0, should work in earlier versions)
- Safari (5-9, iOS 4-9.2, should work in earlier versions)
- Android (4.0-5.1, should work in earlier versions)
- Opera (11, 12, should work in earlier versions)

@@ -240,2 +241,7 @@

1.3.2
- fix to correctly url encode character codes 0-15, such as \n
- include requested URL on response object
- Update tested environments. Removing Firefox 3.6, Safari 5 and iOS 4.3 (no longer supported by SauceLabs). Adding Node 5, Node 4, Edge, Firefox 38 ESR, iOS 9.2, iOS 8.4 and Android 5.1.
1.3.1

@@ -242,0 +248,0 @@ - fix to allow numbers and boolean values as parameters to URI Template expansion.

@@ -28,5 +28,6 @@ /*

'should make a cross origin request': function () {
var request = { path: 'http://ip.jsontest.com/' };
var request = { path: 'https://api.github.com/' };
return client(request).then(function (response) {
assert(response.entity.ip);
assert.match(response.url, 'https://api.github.com/?callback=');
assert(response.entity.data);
assert.same(request, response.request);

@@ -40,2 +41,3 @@ refute(request.canceled);

return jsonpInterceptor()(request).then(function (response) {
assert.match(response.url, '/test/client/fixtures/data.js?callback=callback');
assert(response.entity.data);

@@ -53,2 +55,3 @@ assert.same(request, response.request);

failOnThrow(function (response) {
assert.match(response.url, 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=jsonp&callback=');
assert.same(request, response.request);

@@ -68,2 +71,3 @@ assert(request.canceled);

failOnThrow(function (response) {
assert.match(response.url, 'http://localhost:1234?callback=');
assert.same('loaderror', response.error);

@@ -89,2 +93,3 @@ })

failOnThrow(function (response) {
assert.match(response.url, '/test/client/fixtures/noop.js?callback=');
assert.same('loaderror', response.error);

@@ -99,2 +104,3 @@ })

failOnThrow(function (response) {
assert.match(response.url, '/test/client/fixtures/throw.js?callback=');
assert.same('loaderror', response.error);

@@ -105,4 +111,5 @@ })

'should normalize a string to a request object': function () {
var request = 'http://ip.jsontest.com/';
var request = 'https://api.github.com/';
return client(request).then(function (response) {
assert.match(response.url, 'https://api.github.com/?callback=');
assert.same(request, response.request.path);

@@ -109,0 +116,0 @@ }).otherwise(fail);

@@ -69,2 +69,3 @@ /*

return client(request).then(function (response) {
assert.equals(response.url, 'http://localhost:8080/');
assert(response.raw.request instanceof http.ClientRequest);

@@ -85,2 +86,3 @@ // assert(response.raw.response instanceof http.ClientResponse);

return client(request).then(function (response) {
assert.equals(response.url, 'http://localhost:8080/');
assert.same(request, response.request);

@@ -96,2 +98,3 @@ assert.equals(response.request.method, 'GET');

return client(request).then(function (response) {
assert.equals(response.url, 'http://localhost:8080/');
assert.same(request, response.request);

@@ -109,2 +112,3 @@ assert.equals(response.request.method, 'POST');

return client(request).then(function (response) {
assert.equals(response.url, 'http://localhost:8080/');
assert.same(request, response.request);

@@ -122,2 +126,3 @@ assert.equals(response.request.method, 'POST');

return client(request).then(function (response) {
assert.equals(response.url, 'https://localhost:8443/');
assert(response.raw.request instanceof http.ClientRequest);

@@ -140,3 +145,4 @@ // assert(response.raw.response instanceof http.ClientResponse);

fail,
failOnThrow(function (/* response */) {
failOnThrow(function (response) {
assert.equals(response.url, 'http://localhost:8080/');
assert(request.canceled);

@@ -154,2 +160,3 @@ })

failOnThrow(function (response) {
assert.equals(response.url, 'http://localhost:1234');
assert(response.error);

@@ -172,2 +179,3 @@ })

return client('http://localhost:8080/').then(function (response) {
assert.equals(response.url, 'http://localhost:8080/');
assert.same('http://localhost:8080/', response.request.path);

@@ -174,0 +182,0 @@ }).otherwise(fail);

@@ -33,2 +33,3 @@ /*

return client(request).then(function (response) {
assert.equals(response.url, flickrUrl);
assert.same(request, response.request);

@@ -44,2 +45,3 @@ assert.equals(response.request.method, 'GET');

xdr = response.raw;
assert.equals(response.url, flickrUrl);
assert.same(request, response.request);

@@ -56,2 +58,3 @@ assert.equals(response.request.method, 'GET');

xdr = response.raw;
assert.equals(response.url, flickrUrl);
assert.same(request, response.request);

@@ -68,2 +71,3 @@ assert.equals(response.request.method, 'POST');

xdr = response.raw;
assert.equals(response.url, flickrUrl);
assert.same(request, response.request);

@@ -82,2 +86,3 @@ assert.equals(response.request.method, 'POST');

failOnThrow(function (response) {
assert.match(response.url, flickrUrl + '&q=');
assert(response.request.canceled);

@@ -95,2 +100,3 @@ })

failOnThrow(function (response) {
assert.equals(response.url, 'http://localhost:1234');
assert.same('loaderror', response.error);

@@ -113,2 +119,3 @@ })

return client(flickrUrl).then(function (response) {
assert.equals(response.url, flickrUrl);
assert.same(flickrUrl, response.request.path);

@@ -115,0 +122,0 @@ }).otherwise(fail);

@@ -37,2 +37,3 @@ /*

assert.same(request, response.request);
assert.equals(response.url, '/');
assert.equals(response.request.method, 'GET');

@@ -44,3 +45,5 @@ assert.equals(xhr.responseText, response.entity);

/*jshint forin:false */
assert.equals(xhr.getResponseHeader(name), response.headers[name]);
if (!Array.isArray(response.headers[name])) {
assert.equals(xhr.getResponseHeader(name), response.headers[name]);
}
}

@@ -56,2 +59,3 @@ refute(request.canceled);

assert.same(request, response.request);
assert.equals(response.url, '/');
assert.equals(response.request.method, 'GET');

@@ -63,3 +67,5 @@ assert.equals(xhr.responseText, response.entity);

/*jshint forin:false */
assert.equals(xhr.getResponseHeader(name), response.headers[name]);
if (!Array.isArray(response.headers[name])) {
assert.equals(xhr.getResponseHeader(name), response.headers[name]);
}
}

@@ -75,2 +81,3 @@ refute(request.canceled);

assert.same(request, response.request);
assert.equals(response.url, '/');
assert.equals(response.request.method, 'POST');

@@ -82,3 +89,5 @@ assert.equals(xhr.responseText, response.entity);

/*jshint forin:false */
assert.equals(xhr.getResponseHeader(name), response.headers[name]);
if (!Array.isArray(response.headers[name])) {
assert.equals(xhr.getResponseHeader(name), response.headers[name]);
}
}

@@ -94,2 +103,3 @@ refute(request.canceled);

assert.same(request, response.request);
assert.equals(response.url, '/');
assert.equals(response.request.method, 'POST');

@@ -101,3 +111,5 @@ assert.equals(xhr.responseText, response.entity);

/*jshint forin:false */
assert.equals(xhr.getResponseHeader(name), response.headers[name]);
if (!Array.isArray(response.headers[name])) {
assert.equals(xhr.getResponseHeader(name), response.headers[name]);
}
}

@@ -156,2 +168,3 @@ refute(request.canceled);

failOnThrow(function (response) {
assert.equals(response.url, 'http://localhost:1234');
assert.same('loaderror', response.error);

@@ -180,2 +193,3 @@ })

assert.same(request, response.request);
assert.equals(response.url, '/');
assert.same('xhr-not-available', response.error);

@@ -188,2 +202,3 @@ })

return client('/').then(function (response) {
assert.equals(response.url, '/');
assert.same('/', response.request.path);

@@ -190,0 +205,0 @@ }).otherwise(fail);

@@ -25,3 +25,4 @@ /*

digit: '0123456789',
punctuation: '!"#$%&\'()*+,-./:;<=>?@[]^_`{}~'
punctuation: '!"#$%&\'()*+,-./:;<=>?@[]^_`{}~',
whitespace: '\n\r \t'
};

@@ -43,2 +44,3 @@

assert.same(uriEncoder.encode(strings.punctuation), '%21%22%23%24%25%26%27%28%29%2A%2B%2C-.%2F%3A%3B%3C%3D%3E%3F%40%5B%5D%5E_%60%7B%7D~');
assert.same(uriEncoder.encode(strings.whitespace), '%0A%0D%20%09');
},

@@ -54,2 +56,3 @@ '#encodeScheme()': function () {

assert.same(uriEncoder.encodeScheme(strings.punctuation), '%21%22%23%24%25%26%27%28%29%2A+%2C-.%2F%3A%3B%3C%3D%3E%3F%40%5B%5D%5E%5F%60%7B%7D%7E');
assert.same(uriEncoder.encodeScheme(strings.whitespace), '%0A%0D%20%09');
},

@@ -60,2 +63,3 @@ '#encodeUserInfo()': function () {

assert.same(uriEncoder.encodeUserInfo(strings.punctuation), '!%22%23$%25&\'()*+,-.%2F:;%3C=%3E%3F%40%5B%5D%5E_%60%7B%7D~');
assert.same(uriEncoder.encodeUserInfo(strings.whitespace), '%0A%0D%20%09');
},

@@ -70,2 +74,3 @@ '#encodeHost()': function () {

assert.same(uriEncoder.encodeHost(strings.punctuation), '!%22%23$%25&\'()*+,-.%2F%3A;%3C=%3E%3F%40%5B%5D%5E_%60%7B%7D~');
assert.same(uriEncoder.encodeHost(strings.whitespace), '%0A%0D%20%09');
},

@@ -76,2 +81,3 @@ '#encodePort()': function () {

assert.same(uriEncoder.encodePort(strings.punctuation), '%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F%3A%3B%3C%3D%3E%3F%40%5B%5D%5E%5F%60%7B%7D%7E');
assert.same(uriEncoder.encodePort(strings.whitespace), '%0A%0D%20%09');
},

@@ -85,2 +91,3 @@ '#encodePathSegment()': function () {

assert.same(uriEncoder.encodePathSegment(strings.punctuation), '!%22%23$%25&\'()*+,-.%2F:;%3C=%3E%3F@%5B%5D%5E_%60%7B%7D~');
assert.same(uriEncoder.encodePathSegment(strings.whitespace), '%0A%0D%20%09');
},

@@ -95,2 +102,3 @@ '#encodePath()': function () {

assert.same(uriEncoder.encodePath(strings.punctuation), '!%22%23$%25&\'()*+,-./:;%3C=%3E%3F@%5B%5D%5E_%60%7B%7D~');
assert.same(uriEncoder.encodePath(strings.whitespace), '%0A%0D%20%09');
},

@@ -104,2 +112,3 @@ '#encodeQuery()': function () {

assert.same(uriEncoder.encodeQuery(strings.punctuation), '!%22%23$%25&\'()*+,-./:;%3C=%3E?@%5B%5D%5E_%60%7B%7D~');
assert.same(uriEncoder.encodeQuery(strings.whitespace), '%0A%0D%20%09');
},

@@ -114,2 +123,3 @@ '#encodeFragment()': function () {

assert.same(uriEncoder.encodeFragment(strings.punctuation), '!%22%23$%25&\'()*+,-./:;%3C=%3E?@%5B%5D%5E_%60%7B%7D~');
assert.same(uriEncoder.encodeFragment(strings.whitespace), '%0A%0D%20%09');
},

@@ -116,0 +126,0 @@

@@ -55,3 +55,4 @@ /*

if (code <= 127) {
return '%' + code.toString(16).toUpperCase();
var encoded = code.toString(16).toUpperCase();
return '%' + (encoded.length % 2 === 1 ? '0' : '') + encoded;
}

@@ -58,0 +59,0 @@ else {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc