mirror of
https://github.com/usebruno/bruno.git
synced 2026-06-26 14:15:52 +00:00
Allow leading dot for file and folder names
Co-authored-by: vishnuprasanth-j <jvpvis6@gmail.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const invalidCharacters = /[<>:"/\\|?*\x00-\x1F]/g; // replace invalid characters with hyphens
|
||||
const reservedDeviceNames = /^(CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])$/i;
|
||||
const firstCharacter = /^[^.\s\-<>:"/\\|?*\x00-\x1F]/; // no dot, space, hyphen and `invalidCharacters`
|
||||
const firstCharacter = /^[^\s\-<>:"/\\|?*\x00-\x1F]/; // no space, hyphen and `invalidCharacters`
|
||||
const middleCharacters = /^[^<>:"/\\|?*\x00-\x1F]*$/; // no `invalidCharacters`
|
||||
const lastCharacter = /[^.\s<>:"/\\|?*\x00-\x1F]$/; // no dot, space and `invalidCharacters`
|
||||
|
||||
@@ -9,7 +9,7 @@ export const variableNameRegex = /^[\w-.]*$/;
|
||||
export const sanitizeName = (name) => {
|
||||
name = name
|
||||
.replace(invalidCharacters, '-') // replace invalid characters with hyphens
|
||||
.replace(/^[.\s\-]+/, '') // remove leading dots, spaces and hyphens
|
||||
.replace(/^[\s\-]+/, '') // remove leading spaces and hyphens
|
||||
.replace(/[.\s]+$/, ''); // remove trailing dots and spaces
|
||||
return name;
|
||||
};
|
||||
|
||||
@@ -165,7 +165,7 @@ const sanitizeName = (name) => {
|
||||
const invalidCharacters = /[<>:"/\\|?*\x00-\x1F]/g;
|
||||
name = name
|
||||
.replace(invalidCharacters, '-') // replace invalid characters with hyphens
|
||||
.replace(/^[.\s\-]+/, '') // remove leading dots, spaces and hyphens
|
||||
.replace(/^[\s\-]+/, '') // remove leading spaces and hyphens
|
||||
.replace(/[.\s]+$/, ''); // remove trailing dots and spaces
|
||||
return name;
|
||||
};
|
||||
@@ -177,7 +177,7 @@ const isWindowsOS = () => {
|
||||
const validateName = (name) => {
|
||||
const invalidCharacters = /[<>:"/\\|?*\x00-\x1F]/g; // keeping this for informational purpose
|
||||
const reservedDeviceNames = /^(CON|PRN|AUX|NUL|COM[0-9]|LPT[0-9])$/i;
|
||||
const firstCharacter = /^[^.\s\-<>:"/\\|?*\x00-\x1F]/; // no dot, space, hyphen and `invalidCharacters`
|
||||
const firstCharacter = /^[^\s\-<>:"/\\|?*\x00-\x1F]/; // no space, hyphen and `invalidCharacters`
|
||||
const middleCharacters = /^[^<>:"/\\|?*\x00-\x1F]*$/; // no `invalidCharacters`
|
||||
const lastCharacter = /[^.\s<>:"/\\|?*\x00-\x1F]$/; // no dot, space and `invalidCharacters`
|
||||
if (name.length > 255) return false; // max name length
|
||||
|
||||
Reference in New Issue
Block a user