
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
pathematics
Advanced tools
Parse urls and with Express-like url segments
npm install pathematics --save
Each segement in the source key of the map is injected into the destination value of the map. The map determins which key/value pair to use by comparing the url passed into the method with the map keys.
var pathematics = require('pathematics');
var routesMap = {
'/some/:segemented/route': '/new/route/:segmented'
};
var url = pathematics(routesMap, '/some/custom/route');
console.log(url); // OUTPUTS: /new/route/custom
You can also partialize the function to reuse the object map
var pathematics = require('pathematics');
var routesMap = {
'/some/:segemented/route': '/new/route/:segmented'
};
var paths = pathematics(routesMap);
var url = paths('/some/custom/route');
console.log(url); // OUTPUTS: /new/route/custom
Parseing route segements with custom meta data is also available. If the value if the key/value pair in the object map is an object, it expects the parameter of url
to define the target path with segements.
var pathematics = require('pathematics');
var routesMap = {
'/some/:segemented/route': {
url: '/new/route/:segmented',
metaData: 'something'
}
};
var data = pathematics.withMeta(routesMap, '/some/custom/route');
console.log(data);
/*
OUTPUTS:
{
url: '/new/route/custom',
meta: {
url: '/new/route/:segmented',
metaData: 'something'
}
}
*/
Generates the parsed url with segments if the url is provided or returns a parsing funciton if no url is provided initially.
objectMap
- and object with key values pairs that define routes with segments to match againsturl
- the url to compare and parse with the objectMap
Allows you to pass optional meta data around with route segements with the object map.
npm install
npm test
FAQs
Parse urls and with Express-like url segments
We found that pathematics 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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.