# ant-path-matcher

> An implementation for Ant-style path patterns

Latest version **0.0.5** (published 2021-11-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install ant-path-matcher
pnpm add ant-path-matcher
yarn add ant-path-matcher
bun add ant-path-matcher
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2021-11-08 |
| First published | 2019-05-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 8.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | it@cimc-raffles.com |
| Maintainers | cimc-raffles |
| Keywords | ant, path, matcher |

## Links

- npm: https://www.npmjs.com/package/ant-path-matcher
- Repository: https://github.com/cimc-raffles/ant-path-matcher
- Homepage: https://github.com/cimc-raffles/ant-path-matcher.git
- Issues: https://github.com/cimc-raffles/ant-path-matcher/issues
- npm.io page: https://npm.io/package/ant-path-matcher

## Dependencies (3)

- [xregexp](https://npm.io/package/xregexp.md) ^4.2.4
- [string-builder](https://npm.io/package/string-builder.md) ^0.1.6
- [xregexp-quotemeta](https://npm.io/package/xregexp-quotemeta.md) ^1.0.4

## Alternatives

- [base64url](https://npm.io/package/base64url.md) — 6.1M weekly downloads
- [get-installed-path](https://npm.io/package/get-installed-path.md) — 502.9K weekly downloads
- [@uppy/url](https://npm.io/package/@uppy/url.md) — 185.8K weekly downloads
- [@d3fc/d3fc-shape](https://npm.io/package/@d3fc/d3fc-shape.md) — 16.2K weekly downloads
- [localizer](https://npm.io/package/localizer.md) — 226 weekly downloads

## Recent versions

- 0.0.5 (latest) — 2021-11-08
- 0.0.3 — 2019-05-30
- 0.0.2 — 2019-05-30
- 0.0.1 — 2019-05-27

## README

## Ant-style Path Matcher

An implementation for Ant-style path patterns.  
Part of this mapping code has been kindly borrowed from [Apache Ant](https://ant.apache.org) and [Spring Framework](https://springframework.org).

The mapping matches URLs using the following rules:  
+ ? matches one character  
+ \* matches zero or more characters  
+ \*\* matches zero or more directories in a path  
+ {spring:[a-z]+} matches the regexp [a-z]+ as a path variable named "spring"  


Some examples:
+ com/t?st.jsp — matches com/test.jsp but also com/tast.jsp or com/txst.jsp  
+ com/*.jsp — matches all .jsp files in the com directory  
+ com/**/test.jsp — matches all test.jsp files underneath the com path  
+ org/springframework/**/*.jsp — matches all .jsp files underneath the org/springframework path  
+ org/**/servlet/bla.jsp — matches org/springframework/servlet/bla.jsp but also org/springframework/testing/servlet/bla.jsp and org/servlet/bla.jsp  
+ com/{filename:\\w+}.jsp will match com/test.jsp and assign the value test to the filename variable  



### Installation  

```
npm install ant-path-matcher --save
```

### Usage  

```js
// or: import AntPathMatcher from 'ant-path-matcher'
var AntPathMatcher  = require('ant-path-matcher')

var matcher = new AntPathMatcher() ;

function match( pattern , path) {
 
  console.log( pattern , path , matcher.match( pattern,path)) ;
}

match( '/path/**/?z','/path/x/y/z/xyz') ;

match('/foo/{id}/bar','/foo/1/bar') ;

```

---
_Source: https://npm.io/package/ant-path-matcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
