
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
connect-pushstate
Advanced tools
Connect middleware that rewrites select requests to the site root, allowing your client-side pushstate router to handle them
Connect middleware that rewrites select requests to the site root, allowing your client-side pushstate router to handle them.
Requests including a file extension are left untouched so site assets like your images, stylesheets, and JavaScripts will load unaffected, while requests without a file extension, presumably pages or actions within your site, are rewritten to point at the root, with the original URL intact.
You can also specify regular expressions to specifically allow or disallow additional paths from being affected.
This functionality is commonly needed by single page web-apps.
Install package
npm install connect-pushstate --save
Load the middleware by adding the following line of JavaScript.
var pushState = require('connect-pushstate');
Add the pushState
middleware call to your server definition, amongst your other middleware.
The pushState method accepts an options object as an optional parameter with the following properties.
pushState({ root: '/foo' })
pushState({ allow: '^/api' })
You might need this option if your client app and API are on the same server.pushState({ disallow: '^/version/1.2.3' })
'use strict';
var connect = require('connect');
var morgan = require('morgan');
var serveStatic = require('serve-static');
var pushState = require('connect-pushstate');
var port = process.env.PORT || 3000;
var app = connect()
.use(pushState())
.use(serveStatic('www/'))
.use(morgan('dev'))
.listen(port, function() {
console.log('Application server stated on port', port);
});
Note that serve-static is needed in order to actually serve your files.
For a quick demo, see the examples directory, or run the test suite.
cd examples
node server.js
Execute the test suite
npm test
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.
FAQs
Connect middleware that rewrites select requests to the site root, allowing your client-side pushstate router to handle them
The npm package connect-pushstate receives a total of 25,382 weekly downloads. As such, connect-pushstate popularity was classified as popular.
We found that connect-pushstate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.