Browse Source

admin: clean namespace validation duplication

pull/8273/head
Chris Lu 1 day ago
parent
commit
78c0ecfdcf
  1. 6
      weed/admin/static/js/s3tables.js
  2. 12
      weed/admin/view/app/s3tables_namespaces.templ
  3. 2
      weed/admin/view/app/s3tables_namespaces_templ.go

6
weed/admin/static/js/s3tables.js

@ -731,12 +731,6 @@ function s3TablesNamespaceNameError(name) {
if (!part) {
return 'namespace levels cannot be empty';
}
if (part === '.' || part === '..') {
return "namespace name parts cannot be '.' or '..'";
}
if (part.length < 1 || part.length > 255) {
return 'Namespace name must be between 1 and 255 characters';
}
if (!isLowercaseLetterOrDigit(part[0])) {
return 'Namespace name must start with a letter or digit';
}

12
weed/admin/view/app/s3tables_namespaces.templ

@ -250,14 +250,10 @@ templ S3TablesNamespaces(data dash.S3TablesNamespacesData) {
message = 'namespace levels cannot be empty';
break;
}
if (part === '.' || part === '..') {
message = "namespace name parts cannot be '.' or '..'";
break;
}
const start = part[0];
const end = part[part.length - 1];
const isStartValid = (start >= 'a' && start <= 'z') || (start >= '0' && start <= '9');
const isEndValid = (end >= 'a' && end <= 'z') || (end >= '0' && end <= '9');
const start = part[0];
const end = part[part.length - 1];
const isStartValid = (start >= 'a' && start <= 'z') || (start >= '0' && start <= '9');
const isEndValid = (end >= 'a' && end <= 'z') || (end >= '0' && end <= '9');
if (!isStartValid) {
message = 'Namespace name must start with a letter or digit';
break;

2
weed/admin/view/app/s3tables_namespaces_templ.go
File diff suppressed because it is too large
View File

Loading…
Cancel
Save