Skip to content

Commit 0ec6536

Browse files
committed
File validation fixed
1 parent 5d33d96 commit 0ec6536

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

dist/@litecode-ide/virtual-file-system.es.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3471,7 +3471,7 @@ const $n = ht.createContext(null), Hl = Wl($n), Zl = zl($n), er = Hl, Ke = Zl, G
34713471
children: /* @__PURE__ */ M.jsx("span", { className: "three-dots transition-opacity", children: " " })
34723472
}
34733473
), cr = (e) => `${e}-logo`, Ql = (e, t, r, n, i) => {
3474-
const o = /^([^\\]*)\.(\w+)$/, s = /^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*[a-zA-Z0-9])?\.[a-zA-Z0-9_-]+$/, a = /^[a-z0-9._]+$/i, l = t.match(s), c = t.match(o), u = t.match(a);
3474+
const o = /^([^\\]*)\.(\w+)$/, s = /^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*[a-zA-Z0-9])?\.[a-zA-Z0-9_-]+$/, a = /^[a-z0-9._-]+$/i, l = t.match(s), c = t.match(o), u = t.match(a);
34753475
if (c && u) {
34763476
const h = n, g = c[1], d = c[2];
34773477
if (l && u && h.includes(d)) {
@@ -3514,7 +3514,7 @@ const $n = ht.createContext(null), Hl = Wl($n), Zl = zl($n), er = Hl, Ke = Zl, G
35143514
errorMessage: ""
35153515
};
35163516
}, ec = (e, t) => {
3517-
const r = /^[a-zA-Z0-9_-\s]+$/;
3517+
const r = /^[a-zA-Z0-9_[\]-\s]+$/;
35183518
if (e.match(r) || e === "") {
35193519
for (const { wholeName: i, type: o } of t)
35203520
if (i.toLowerCase() === e.toLowerCase() && o === "folder")
@@ -9886,7 +9886,7 @@ const yr = ({ children: e }) => /* @__PURE__ */ M.jsxs(Ul, { context: $n, store:
98869886
children: /* @__PURE__ */ M.jsx("div", { className: "breadcrumbs-container flex items-center justify-start m-2", children: b.path.map((v, m) => /* @__PURE__ */ M.jsx(
98879887
"div",
98889888
{
9889-
id: `${b.path.map((w) => w.replace(/[\.|\s]+/g, "-")).join("")}-${m}`,
9889+
id: `${b.path.map((w) => w.replace(/[.[\]|\s]+/g, "-")).join("")}-${m}`,
98909890
children: /* @__PURE__ */ M.jsxs(
98919891
"div",
98929892
{
@@ -9917,12 +9917,12 @@ const yr = ({ children: e }) => /* @__PURE__ */ M.jsxs(Ul, { context: $n, store:
99179917
}
99189918
)
99199919
},
9920-
`${b.path.map((w) => w.replace(/[\.|\s]+/g, "-")).join("")}-${m}`
9920+
`${b.path.map((w) => w.replace(/[.[\]|\s]+/g, "-")).join("")}-${m}`
99219921
)) })
99229922
}
99239923
),
99249924
g.current && c && /* @__PURE__ */ M.jsx(M.Fragment, { children: (() => {
9925-
const v = `${b.path.map((w) => w.replace(/[\.|\s]+/g, "-")).join("")}-${a}`, m = g.current.querySelector(
9925+
const v = `${b.path.map((w) => w.replace(/[.[\]|\s]+/g, "-")).join("")}-${a}`, m = g.current.querySelector(
99269926
`#${v}`
99279927
);
99289928
if (m)

dist/@litecode-ide/virtual-file-system.umd.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/file-structure/utils/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ const validateFile = (
7777
const regexFileName =
7878
/^[a-zA-Z0-9](?:[a-zA-Z0-9 ._-]*[a-zA-Z0-9])?\.[a-zA-Z0-9_-]+$/;
7979

80-
const lettersNumbersSymbols = /^[a-z0-9._]+$/i;
80+
const lettersNumbersSymbols = /^[a-z0-9._-]+$/i;
8181

8282
const isValid = value.match(regexFileName);
8383
const matches = value.match(regex);
@@ -187,7 +187,7 @@ const validateFolder = (
187187
value: string,
188188
existingItems: Array<{ wholeName: string; type: string }>
189189
): { error: boolean; errorMessage: string } => {
190-
const regex = /^[a-zA-Z0-9_-\s]+$/;
190+
const regex = /^[a-zA-Z0-9_[\]-\s]+$/;
191191
const isValid = value.match(regex);
192192

193193
if (isValid || value === "") {

src/components/menus/Breadcrumbs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,10 @@ const Breadcrumbs: React.FC<BreadcrumbsProps> = ({
5656
{editorObj.path.map((path, i) => (
5757
<div
5858
id={`${editorObj.path
59-
.map((path) => path.replace(/[\.|\s]+/g, "-"))
59+
.map((path) => path.replace(/[.[\]|\s]+/g, "-"))
6060
.join("")}-${i}`}
6161
key={`${editorObj.path
62-
.map((path) => path.replace(/[\.|\s]+/g, "-"))
62+
.map((path) => path.replace(/[.[\]|\s]+/g, "-"))
6363
.join("")}-${i}`}
6464
>
6565
<div
@@ -98,7 +98,7 @@ const Breadcrumbs: React.FC<BreadcrumbsProps> = ({
9898
<>
9999
{(() => {
100100
const id = `${editorObj.path
101-
.map((path) => path.replace(/[\.|\s]+/g, "-"))
101+
.map((path) => path.replace(/[.[\]|\s]+/g, "-"))
102102
.join("")}-${clickedIndex}`;
103103

104104
const element = breadcrumbsRef.current.querySelector(

0 commit comments

Comments
 (0)