Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown';
import camelCase from 'lodash/camelCase';
import upperFirst from 'lodash/upperFirst';

import { DialogCreationCopy, nameRegexV2 } from '../../../constants';
import { DialogCreationCopy, nameRegexV2, nameRegex } from '../../../constants';
import { FieldConfig, useForm } from '../../../hooks/useForm';
import { StorageFolder } from '../../../recoilModel/types';
import { createNotification } from '../../../recoilModel/dispatchers/notification';
Expand Down Expand Up @@ -159,7 +159,9 @@ const DefineConversationV2: React.FC<DefineConversationProps> = (props) => {
name: {
required: true,
validate: (value) => {
if (!value || !nameRegexV2.test(`${value}`)) {
const isPvaBot = templateId === 'pva';
const namePattern = isPvaBot ? nameRegex : nameRegexV2;
if (!value || !namePattern.test(`${value}`)) {
// botName is used as used when generating runtime namespaces which cannot start with a number
if (value && !isNaN(+value.toString().charAt(0))) {
return formatMessage('Bot name cannot start with a number or space');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import axios from 'axios';

import { dispatcherState } from '../../recoilModel';
import { createNotification } from '../../recoilModel/dispatchers/notification';
import { invalidNameCharRegex } from '../../constants';

import { ImportStatus } from './ImportStatus';
import { ImportSuccessNotificationWrapper } from './ImportSuccessNotification';
Expand Down Expand Up @@ -75,7 +76,8 @@ export const ImportModal: React.FC<RouteComponentProps> = (props) => {

const searchParams = new URLSearchParams();
if (name) {
searchParams.set('name', encodeURIComponent(name));
const validName = source === 'pva' ? name.replace(invalidNameCharRegex, '-') : name;
searchParams.set('name', encodeURIComponent(validName));
}
if (description) {
searchParams.set('description', encodeURIComponent(description));
Expand Down
3 changes: 2 additions & 1 deletion Composer/packages/client/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ export const nameRegex = /^[a-zA-Z0-9-_]+$/;

export const nameRegexV2 = /^[a-zA-Z0-9_]+$/;

export const invalidNameCharRegex = /[^a-z^A-Z^0-9^_]/g;
export const invalidNameCharRegex = /[^a-zA-Z0-9-_]/g;
export const invalidNameCharRegexV2 = /[^a-zA-Z0-9_]/g;

export const authConfig = {
// for web login
Expand Down