
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
hash-regex-router
Advanced tools
Client-side hashchange regex router for [singe-page applications](http://en.wikipedia.org/wiki/Single-page_application). Works on Chrome 5, Firefox 3.6 and IE 10+.
Client-side hashchange regex router for singe-page applications. Works on Chrome 5, Firefox 3.6 and IE 10+.
Routes are processed in the order they are added.
Basic usage:
route(/^about/, function() {
console.log('Showing the About page');
});
With capture groups:
route(/^profile\/([0-9]+)/, function(uid) {
console.log('Showing the profile page for user ' + uid);
});
Default route:
route(/.*/, function() {
route.go('home');
});
Programmatically go to a route (#home):
route.go('home');
Goes to #profile/123:
route.go('profile', 123);
Refresh the current route:
route.refresh();
Disable routing:
route.disable();
Re-enable routing:
route.enable();
Prevent leaving current route:
route.leave = function() {
return confirm('Leave the current route?');
};
The source router.js
uses CommonJS module format. dist/router-standalone.js
contains minified build in UMD format that supports both AMD and CommonJS environments and also
sets global route
when directly in browser.
Installing from NPM:
npm install hash-regex-router
If installed through NPM then the module can be directly used in browserify by simply require()'ing it:
var route = require('router');
Install build dependencies:
npm install
Run static server:
make serve-test
Run tests:
make test
The MIT license.
FAQs
Client-side hashchange regex router for [singe-page applications](http://en.wikipedia.org/wiki/Single-page_application). Works on Chrome 5, Firefox 3.6 and IE 10+.
The npm package hash-regex-router receives a total of 8 weekly downloads. As such, hash-regex-router popularity was classified as not popular.
We found that hash-regex-router 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.