Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-pagination

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-pagination - npm Package Compare versions

Comparing version 0.3.1 to 1.0.0

5

CHANGELOG.md
## Changelog
### 1.0.0 / 2015-12-10
- [#25](https://github.com/seegno/koa-pagination/pull/25) Remove usage of `chai` (@franciscocardoso)
- [#24](https://github.com/seegno/koa-pagination/pull/24) Prevent usage of unsafe numbers (@franciscocardoso)
- [#23](https://github.com/seegno/koa-pagination/pull/23) Replace `create-error` with `standard-http-error` (@franciscocardoso)
### 0.3.1 / 2015-02-26

@@ -4,0 +9,0 @@ - [#21](https://github.com/seegno/koa-pagination/pull/21) Fix readme headers example (@nunorafaelrocha)

19

errors/invalid-configuration-error.js

@@ -6,8 +6,23 @@

var errors = require('create-error');
const HttpError = require('standard-http-error');
const util = require('util');
/**
* Constructor.
*/
function InvalidConfigurationError() {
HttpError.call(this);
}
/**
* Inherit from `HttpError`.
*/
util.inherits(InvalidConfigurationError, HttpError);
/**
* Export `InvalidConfigurationError`.
*/
module.exports = errors('InvalidConfigurationError');
module.exports = InvalidConfigurationError;

@@ -6,8 +6,23 @@

var errors = require('create-error');
const HttpError = require('standard-http-error');
const util = require('util');
/**
* Constructor.
*/
function MalformedRangeError(message, properties) {
HttpError.call(this, 412, message, properties);
}
/**
* Inherit from `HttpError`.
*/
util.inherits(MalformedRangeError, HttpError);
/**
* Export `MalformedRangeError`.
*/
module.exports = errors('MalformedRangeError', { status: 412 });
module.exports = MalformedRangeError;

@@ -6,8 +6,23 @@

var errors = require('create-error');
const HttpError = require('standard-http-error');
const util = require('util');
/**
* Constructor.
*/
function RangeNotSatisfiableError(message, properties) {
HttpError.call(this, 416, message, properties);
}
/**
* Inherit from `HttpError`.
*/
util.inherits(RangeNotSatisfiableError, HttpError);
/**
* Export `RangeNotSatisfiableError`.
*/
module.exports = errors('RangeNotSatisfiableError', { status: 416 });
module.exports = RangeNotSatisfiableError;

@@ -11,2 +11,3 @@

var contentRangeFormat = require('http-content-range-format');
var isSafeInteger = require('is-safe-integer');
var rangeSpecifierParser = require('range-specifier-parser');

@@ -31,3 +32,3 @@

// Prevent invalid `maximum` value configuration.
if (!_.isFinite(maximum) || maximum <= 0) {
if (!_.isFinite(maximum) || !isSafeInteger(maximum) || maximum <= 0) {
throw new InvalidConfigurationError();

@@ -52,2 +53,6 @@ }

unit = range.unit;
if (!isSafeInteger(first) || !isSafeInteger(last)) {
throw new RangeNotSatisfiableError();
}
}

@@ -54,0 +59,0 @@

6

package.json
{
"name": "koa-pagination",
"version": "0.3.1",
"version": "1.0.0",
"description": "Koa Pagination",

@@ -10,11 +10,11 @@ "main": "index.js",

"dependencies": {
"create-error": "0.3.1",
"debug": "2.1.0",
"http-content-range-format": "1.0.0",
"is-safe-integer": "^1.0.1",
"lodash": "2.4.1",
"range-specifier-parser": "0.1.0",
"standard-http-error": "2.0.0",
"util": "0.10.3"
},
"devDependencies": {
"chai": "1.10.0",
"co-mocha": "1.0.2",

@@ -21,0 +21,0 @@ "co-supertest": "0.0.7",

@@ -6,3 +6,2 @@

var chai = require('chai');
var koa = require('koa');

@@ -13,4 +12,2 @@ var paginate = require('../');

chai.should();
/**

@@ -103,2 +100,13 @@ * Test `paginate`.

it('should give and error if `maximum` is not a safe integer', function *() {
var app = koa();
app.use(paginate({ maximum: 9007199254740993 }));
yield request(app.listen())
.get('/')
.expect(500)
.end();
});
it('should accept a `Range` header', function *() {

@@ -188,2 +196,26 @@ var app = koa();

it('should give and error if `first position` is not a safe integer', function *() {
var app = koa();
app.use(paginate());
yield request(app.listen())
.get('/')
.set('Range', 'items=9007199254740992-9007199254740993')
.expect(416)
.end();
});
it('should give and error if `last position` is not a safe integer', function *() {
var app = koa();
app.use(paginate());
yield request(app.listen())
.get('/')
.set('Range', 'items=1-9007199254740992')
.expect(416)
.end();
});
it('should not allow `last position` value to be higher than `length`', function *() {

@@ -190,0 +222,0 @@ var app = koa();

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