GithubHelp home page GithubHelp logo

filename-reserved-regex's Introduction

filename-reserved-regex

Regular expression for matching reserved filename characters

On Unix-like systems / is reserved and <>:"/\|?* as well as non-printable characters \u0000-\u001F on Windows.

Install

$ npm install filename-reserved-regex

Usage

import filenameReservedRegex, {windowsReservedNameRegex} from 'filename-reserved-regex';

filenameReservedRegex().test('foo/bar');
//=> true

filenameReservedRegex().test('foo-bar');
//=> false

'foo/bar'.replace(filenameReservedRegex(), '!');
//=> 'foo!bar'

windowsReservedNameRegex().test('aux');
//=> true

API

filenameReservedRegex()

Returns a regex that matches all invalid characters.

windowsReservedNameRegex()

Returns an 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.

filename-reserved-regex's People

Contributors

sindresorhus avatar silverwind avatar sonicdoe avatar richienb avatar

Stargazers

Sara Tasche avatar  avatar longmo avatar Joep Kockelkorn avatar 云泥 avatar  avatar Eric avatar Per Tillisch avatar  avatar Rowanelizabeth avatar 鸿则 avatar Fabio Spampinato avatar Mindula Dilthushan Manamperi avatar Tobias Zittlau avatar Raymel Francisco avatar NNashwin avatar Bob "Wombat" Hogg avatar Zitao Xiong avatar Dean Lofts avatar  avatar Alexandre Nicastro avatar Adavidoaiei Dumitru-Cornel avatar Nurul Sundarani avatar Pacharapol Withayasakpunt avatar David Wells avatar Muhammad Farid Zia avatar Shawn Charles avatar Lúcio Caetano avatar swyx.io avatar Tyler Richards avatar  avatar deepskyblue avatar  avatar Damien Golding avatar Whoami avatar Pavel Birukov  avatar Sean Zhou avatar Julien avatar Adrian Perez avatar Vincenzo Ferrari avatar Jannis R avatar darcy avatar  avatar  avatar azu avatar Franco Correa avatar BJR Matos avatar James Yang avatar Johnie Hjelm avatar  avatar

Watchers

 avatar Kevin Mårtensson avatar James Cloos avatar Sam Verschueren avatar Arthur Verschaeve avatar  avatar

filename-reserved-regex's Issues

Supporting import

Hi,

I'm getting the following error when importing this package:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /redacted/path/node_modules/filename-reserved-regex/index.js
require() of ES modules is not supported.
require() of /redacted/path/node_modules/filename-reserved-regex/index.js from /redacted/path/build/server.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /redacted/path/node_modules/filename-reserved-regex/package.json.

at new NodeError (node:internal/errors:363:5)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1112:13)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:816:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:93:18)
at Object.<anonymous> (/redacted/path/build/server.js:22:46)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
at Module.load (node:internal/modules/cjs/loader:975:32)

ERROR: "dev:server" exited with 1.

It is possible to implement one of the suggestions in the error?

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.