Security News
PyPI’s New Archival Feature Closes a Major Security Gap
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
grunt-connect-pushstate
Advanced tools
A grunt plugin that provides connect middleware to rewrite requests allowing for pushstate routing
A grunt plugin that provides connect middleware to rewrite select requests to the site root (or a custom defined root), thus allowing for pushstate routing.
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, thus allowing your pushstate router to handle the request.
This plugin is designed for use with the grunt-contrib-connect plugin.
This plugin requires Grunt ~0.4.1
If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:
npm install grunt-connect-pushstate --save
Load the middleware by adding the following line of JavaScript to the top of your project's Gruntfile.
var pushState = require('grunt-connect-pushstate/lib/utils').pushState;
Adjust the "connect" task by adding the pushState() middleware call to the connect options middleware hook, amongst your other middleware. You can customize the root path by passing it in as a parameter. eg) pushState('/somewhere/')
Note that connect.static is needed as well.
connect: {
options: {
hostname: 'localhost',
port: 3000,
base: 'www/',
middleware: function (connect, options) {
return [
// Rewrite requests to root so they may be handled by router
pushState(),
// Serve static files
connect.static(options.base)
];
}
}
}
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 using Grunt.
Suggestions for improvement and/or added flexibility are very welcome. :)
FAQs
A grunt plugin that provides connect middleware to rewrite requests allowing for pushstate routing
The npm package grunt-connect-pushstate receives a total of 6 weekly downloads. As such, grunt-connect-pushstate popularity was classified as not popular.
We found that grunt-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.
Security News
PyPI now allows maintainers to archive projects, improving security and helping users make informed decisions about their dependencies.
Research
Security News
Malicious npm package postcss-optimizer delivers BeaverTail malware, targeting developer systems; similarities to past campaigns suggest a North Korean connection.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.