Skip to content

Commit

Permalink
do not force dialog name to lowercase (microsoft#3817)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixzhan authored Aug 10, 2020
1 parent a176a02 commit 0c3c06b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 23 deletions.
24 changes: 3 additions & 21 deletions Composer/packages/lib/indexers/src/utils/dialogCheckUtil.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import has from 'lodash/has';
import { SDKKinds } from '@bfc/shared';

import { VisitorFunc, JsonWalk } from './jsonWalk';

/**
* fix dialog referrence.
* - "dialog": 'AddTodos'
* + "dialog": 'addtodos'
* fix dialog's lg/lu referrence, use dialog's lg/lu file
*/
export function autofixReferInDialog(dialogId: string, content: string): string {
try {
const dialogJson = JSON.parse(content);

// fix dialog referrence
const visitor: VisitorFunc = (_path: string, value: any) => {
if (has(value, '$type') && value.$type === SDKKinds.BeginDialog) {
const dialogName = value.dialog;
value.dialog = dialogName.toLowerCase();
}
return false;
};

JsonWalk('/', dialogJson, visitor);

// fix lg referrence
dialogJson.generator = `${dialogId.toLowerCase()}.lg`;
dialogJson.generator = `${dialogId}.lg`;

// fix lu referrence
if (typeof dialogJson.recognizer === 'string') {
dialogJson.recognizer = `${dialogId.toLowerCase()}.lu`;
dialogJson.recognizer = `${dialogId}.lu`;
}
return JSON.stringify(dialogJson, null, 2);
} catch (_error) {
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/server/src/models/bot/botStructure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export const defaultFilePath = (botName: string, defaultLocale: string, filename
});
}

const DIALOGNAME = fileId.toLowerCase();
const isRootFile = BOTNAME === DIALOGNAME;
const DIALOGNAME = fileId;
const isRootFile = BOTNAME === DIALOGNAME.toLowerCase();

let TemplatePath = '';
if (fileType === FileExtensions.Dialog) {
Expand Down

0 comments on commit 0c3c06b

Please sign in to comment.