GitShow/sindresorhus/filename-reserved-regex
sindresorhus

filename-reserved-regex

Regular expression for matching reserved filename characters

by sindresorhus
Star on GitHubForknpm

JavaScript

52 stars5 forks4 contributorsQuiet · 11mo agoSince 2015v4.0.0MIT

Meet the team

See all 4 on GitHub →
sindresorhus
sindresorhus12 contributions
silverwind
silverwind2 contributions
sonicdoe
sonicdoe1 contribution
Richienb
Richienb1 contribution

Languages

View on GitHub →
JavaScript100%

Commit activity

Last 12 weeks · 0 commits

Full graph →

Community health

4 of 6 standards met

Community profile →
85
✓README✓License✓Contributing✓Code of Conduct○Issue Template○PR Template

Recent PRs & issues

Quiet · 1 in progress · Last activity 11mo ago
See all on GitHub →
FatalBulletHit
Enhance windowsReservedNameRegexOpenPR

Updated the windowsReservedNameRegex function to include additional invalid Windows filenames (see #5 ). Updated the README accordingly.

FatalBulletHit · 2d ago
FatalBulletHit
"windowsReservedNameRegex" is incompleteOpenIssue

According to Microsoft's Naming Conventions: Do not use the following reserved names for the name of a file: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, COM¹, COM², COM³, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, LPT9, LPT¹, LPT², and LPT³. Also avoid these names followed immediately by an extension; for example, NUL.txt and NUL.tar.gz are both equivalent to NUL. For more information, see Namespaces. Note Windows recognizes the 8-bit ISO/IEC 8859-1 superscript digits ¹, ², and ³ as digits and treats them as valid parts of COM# and LPT# device names, making them reserved in every directory. For example, echo test > COM¹ fails to create a file. The regex neither checks for superscript digits nor for reserved names immediately followed by an extension: https://github.com/sindresorhus/filename-reserved-regex/blob/1403e86e937f0955fbb0ffad4ce56fbae47e3cc0/index.js#L8 It should probably be something like this (excluding 0 as it should be valid):

FatalBulletHit · 3d ago

Recent fixes

View closed PRs →
silverwind
Match Windows filenames ending in space or periodClosedIssue

From https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#naming-conventions: Do not end a file or directory name with a space or a period. Although the underlying file system may support such names, the Windows shell and user interface does not. They should be added the the Windows Regexp.

silverwind · 11mo ago
mike-stewart-dev
Supporting importClosedIssue

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. (/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

mike-stewart-dev · 4y ago
Richienb
Move to GitHub ActionsMergedPR
Richienb · 5y ago
Structured data for AI agents

Repository: sindresorhus/filename-reserved-regex. Description: Regular expression for matching reserved filename characters Stars: 52, Forks: 5. Primary language: JavaScript. Languages: JavaScript (100%). License: MIT. Latest release: v4.0.0 (11mo ago). Open PRs: 1, open issues: 1. Last activity: 11mo ago. Community health: 85%. Top contributors: sindresorhus, silverwind, sonicdoe, Richienb.

·@ofershap

Replace github.com with gitshow.dev