UNPKG

path-ends-with

Version:

Return `true` if a file path ends with the given string/suffix.

121 lines (75 loc) 4.53 kB
# path-ends-with [![NPM version](https://img.shields.io/npm/v/path-ends-with.svg?style=flat)](https://www.npmjs.com/package/path-ends-with) [![NPM monthly downloads](https://img.shields.io/npm/dm/path-ends-with.svg?style=flat)](https://npmjs.org/package/path-ends-with) [![NPM total downloads](https://img.shields.io/npm/dt/path-ends-with.svg?style=flat)](https://npmjs.org/package/path-ends-with) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/path-ends-with.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/path-ends-with) [![Windows Build Status](https://img.shields.io/appveyor/ci/jonschlinkert/path-ends-with.svg?style=flat&label=AppVeyor)](https://ci.appveyor.com/project/jonschlinkert/path-ends-with) > Return `true` if a file path ends with the given string/suffix. Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support. ## Install Install with [npm](https://www.npmjs.com/): ```sh $ npm install --save path-ends-with ``` ## Usage ```js const endsWith = require('path-ends-with'); console.log(endsWith('foobar', 'bar')); //=> false console.log(endsWith('foo/bar', 'bar')); //=> true ``` ## Options ### options.nocase **Type**: `boolean` **Default**: `undefined` Enable case sensitivity. ```js endsWith('foo/bar', 'BAR'); //=> false endsWith('foo/bar', 'BAR', { nocase: true }); //=> true ``` ### options.partialMatch **Type**: `boolean` **Default**: `false` Allow matching against part of a path segment. ```js endsWith('foobar', 'bar'); //=> false endsWith('foobar', 'bar', { partialMatch: true }); //=> true ``` ## Release history ### v2.0 **Breaking changes** * No longer supports leading `!` as a negation character. ## About <details> <summary><strong>Contributing</strong></summary> Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). </details> <details> <summary><strong>Running Tests</strong></summary> Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: ```sh $ npm install && npm test ``` </details> <details> <summary><strong>Building docs</strong></summary> _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ To generate the readme, run the following command: ```sh $ npm install -g verbose/verb#dev verb-generate-readme && verb ``` </details> ### Related projects You might also be interested in these projects: * [contains-path](https://www.npmjs.com/package/contains-path): Return true if a file path contains the given path. | [homepage](https://github.com/jonschlinkert/contains-path "Return true if a file path contains the given path.") * [ends-with](https://www.npmjs.com/package/ends-with): Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for… [more](https://github.com/jonschlinkert/ends-with) | [homepage](https://github.com/jonschlinkert/ends-with "Returns `true` if the given `string` or `array` ends with `suffix` using strict equality for comparisons.") * [normalize-path](https://www.npmjs.com/package/normalize-path): Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a… [more](https://github.com/jonschlinkert/normalize-path) | [homepage](https://github.com/jonschlinkert/normalize-path "Normalize file path slashes to be unix-like forward slashes. Also condenses repeat slashes to a single slash and removes and trailing slashes unless disabled.") * [unixify](https://www.npmjs.com/package/unixify): Convert Windows file paths to unix paths. | [homepage](https://github.com/jonschlinkert/unixify "Convert Windows file paths to unix paths.") ### Author **Jon Schlinkert** * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert) * [GitHub Profile](https://github.com/jonschlinkert) * [Twitter Profile](https://twitter.com/jonschlinkert) ### License Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert). Released under the [MIT License](LICENSE). *** _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on March 17, 2018._