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

hmpo-form-controller

Package Overview
Dependencies
Maintainers
3
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hmpo-form-controller - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

10

lib/form.js

@@ -152,3 +152,6 @@ var util = require('util'),

var next = this.options.next || req.path;
return req.baseUrl + next;
if (req.baseUrl !== '/') {
next = req.baseUrl + next;
}
return next;
},

@@ -163,3 +166,6 @@ getErrorStep: function (err, req) {

}
return req.baseUrl + redirect;
if (req.baseUrl !== '/') {
redirect = req.baseUrl + redirect;
}
return redirect;
},

@@ -166,0 +172,0 @@ isValidationError: function (err) {

3

package.json
{
"name": "hmpo-form-controller",
"version": "0.0.5",
"version": "0.0.6",
"description": "",

@@ -33,2 +33,3 @@ "main": "index.js",

"postcode": "^0.2.2",
"reqres": "^1.1.1",
"sinon": "^1.12.2",

@@ -35,0 +36,0 @@ "sinon-chai": "^2.6.0"

module.exports = function (req) {
req.form = req.form || {};
req.form.values = req.form.values || {};
req.session = req.session || {};
req.flash = req.flash || sinon.stub().returns([]);
req.baseUrl = '';
req.params = req.params || {};
return req;
return require('reqres').req(req);
};

@@ -168,3 +168,2 @@ var Form = require('../../');

it('passes output of getValues to the rendered template', function () {
req.flash.returns([]);
form.getValues.yields(null, { values: [1] });

@@ -176,3 +175,2 @@ form.get(req, res, cb);

it('calls callback with error if getValues fails', function () {
req.flash.returns([]);
form.getValues.yields({ error: 'message' });

@@ -446,3 +444,3 @@ form.get(req, res, cb);

beforeEach(function () {
form = new Form({ template: 'index', next: 'success' });
form = new Form({ template: 'index', next: '/success' });
req = request({

@@ -460,9 +458,9 @@ params: {},

form.successHandler(req, res);
res.redirect.should.have.been.calledWith('success');
res.redirect.should.have.been.calledWith('/success');
});
it('prefixes redirect url with req.baseUrl', function () {
req.baseUrl = 'base/';
req.baseUrl = '/base';
form.successHandler(req, res);
res.redirect.should.have.been.calledWith('base/success');
res.redirect.should.have.been.calledWith('/base/success');
});

@@ -485,3 +483,3 @@

err = new Form.Error('field');
form = new Form({ template: 'index', next: 'success' });
form = new Form({ template: 'index', next: '/success' });
req = request({

@@ -488,0 +486,0 @@ path: '/index',

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