1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 23:48:47 +00:00

update-dir-file-path-validation (#6958)

* update-dir-file-path-validation

* Update utils.js
This commit is contained in:
Ranjiwei
2024-10-31 09:33:21 +08:00
committed by GitHub
parent 615163802b
commit 20fde74744
5 changed files with 56 additions and 10 deletions

View File

@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Alert } from 'reactstrap';
import { gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import { Utils, validateName } from '../../utils/utils';
const propTypes = {
fileType: PropTypes.string,
@@ -54,9 +54,13 @@ class CreateFile extends React.Component {
if (!this.state.isSubmitBtnActive) {
return;
}
let isDuplicated = this.checkDuplicatedName();
let newName = this.state.childName;
let newName = this.state.childName.trim();
let { isValid, errMessage } = validateName(newName);
if (!isValid) {
this.setState({ errMessage });
return;
}
if (isDuplicated) {
let errMessage = gettext('The name "{name}" is already taken. Please choose a different name.');

View File

@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Button, Modal, ModalHeader, Input, ModalBody, ModalFooter, Form, FormGroup, Label, Alert } from 'reactstrap';
import { gettext } from '../../utils/constants';
import { Utils } from '../../utils/utils';
import { Utils, validateName } from '../../utils/utils';
const propTypes = {
fileType: PropTypes.string,
@@ -46,9 +46,13 @@ class CreateForder extends React.Component {
if (!this.state.isSubmitBtnActive) {
return;
}
let newName = this.state.childName;
let isDuplicated = this.checkDuplicatedName();
let newName = this.state.childName.trim();
let { isValid, errMessage } = validateName(newName);
if (!isValid) {
this.setState({ errMessage });
return;
}
if (isDuplicated) {
let errMessage = gettext('The name "{name}" is already taken. Please choose a different name.');