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

egg-path-matching

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

egg-path-matching

match or ignore url path

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
22K
decreased by-0.17%
Maintainers
2
Weekly downloads
 
Created
Source

egg-path-matching

NPM version CI Test coverage Known Vulnerabilities npm download

Installation

npm install egg-path-matching

Usage

import { pathMatching } from 'egg-path-matching';

const options = {
  ignore: '/api', // string will use parsed by path-to-regexp
  // support regexp
  ignore: /^\/api/,
  // support function
  ignore: ctx => ctx.path.startsWith('/api'),
  // support Array
  ignore: [ ctx => ctx.path.startsWith('/api'), /^\/foo$/, '/bar'],
  // support match or ignore
  match: '/api',
};

const match = pathMatching(options);
assert.equal(match({ path: '/api' }), true);
assert.equal(match({ path: '/api/hello' }), true);
assert.equal(match({ path: '/api' }), true);

options

  • match {String | RegExp | Function | Array} - if request path hit options.match, will return true, otherwise will return false.
  • ignore {String | RegExp | Function | Array} - if request path hit options.ignore, will return false, otherwise will return true.

ignore and match can not both be presented. and if neither ignore nor match presented, the new function will always return true.

License

MIT

Contributors

Contributors

Made with contributors-img.

Keywords

FAQs

Package last updated on 18 Sep 2024

Did you know?

Socket

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.

Install

Related posts

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