https://github.com/bentatum/is-valid-path-with-extension
Returns true if a file path has valid characters and file extension matches provided pattern.
https://github.com/bentatum/is-valid-path-with-extension
Last synced: about 2 months ago
JSON representation
Returns true if a file path has valid characters and file extension matches provided pattern.
- Host: GitHub
- URL: https://github.com/bentatum/is-valid-path-with-extension
- Owner: bentatum
- Created: 2016-05-17T20:18:57.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-19T14:21:34.000Z (about 9 years ago)
- Last Synced: 2025-03-27T04:17:48.355Z (about 2 months ago)
- Language: JavaScript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
[](https://badge.fury.io/js/is-valid-path-with-extension)
# is-valid-path-with-extension
Returns true if a file path has valid characters and file extension matches.Based on [is-valid-path] (https://www.npmjs.com/package/is-valid-path). Thanks [jonschlinkert](https://github.com/jonschlinkert).
Here is a way to tell if string is a valid path of a particular file type. It's essentially is-valid-path with a second argument for a regex pattern. 🙂
```javascript
import { default as isValid } from 'is-valid-path-with-extension'isValid('img.jpg', /\.jpg/) // true
isValid('img.jpg', /\.png/) // null
isValid('img.jpg', /\.jpg|\.jpeg|\.png|\.svg/) // true
isValid('img.jp', /\.jpg|\.jpeg|\.png|\.svg/) // null
```