Bakhtina Sofya b84cb877be 1st comm | 3 周之前 | |
---|---|---|
.. | ||
index.js | 3 周之前 | |
license | 3 周之前 | |
package.json | 3 周之前 | |
readme.md | 3 周之前 |
Regular expression for matching reserved filename characters
On Unix-like systems /
is reserved and <>:"/\|?*
as well as non-printable characters \x00-\x1F
on Windows.
$ npm install --save filename-reserved-regex
const filenameReservedRegex = require('filename-reserved-regex');
filenameReservedRegex().test('foo/bar');
//=> true
filenameReservedRegex().test('foo-bar');
//=> false
'foo/bar'.replace(filenameReservedRegex(), '!');
//=> 'foo!bar'
filenameReservedRegex.windowsNames().test('aux');
//=> true
Returns a regex that matches all invalid characters.
Returns a exact-match case-insensitive regex that matches invalid Windows
filenames. These include CON
, PRN
, AUX
, NUL
, COM1
, COM2
, COM3
, COM4
, COM5
,
COM6
, COM7
, COM8
, COM9
, LPT1
, LPT2
, LPT3
, LPT4
, LPT5
, LPT6
, LPT7
, LPT8
and LPT9
.
MIT © Sindre Sorhus