-
Notifications
You must be signed in to change notification settings - Fork 376
fix: [#9528] Unable to add two PVA bot skills through bot framework composer with the option connect to a skill #9549
Changes from 3 commits
b6b1507
1a18e3a
793982d
d4dbcc0
72cd093
0e22f61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,9 @@ import { rootBotProjectIdSelector } from '../selectors'; | |
| import { setRootBotSettingState } from './setting'; | ||
| import { addSkillFiles, deleteSkillFiles } from './utils/skills'; | ||
|
|
||
| const urlRegex = /^http[s]?:\/\/\w+/; | ||
| const isExternalLink = (url: string): boolean => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: const isExternalLink = (url: string): boolean => {
const { origin } = location;
const parsedUrl = new URL(url, origin);
return parsedUrl.origin !== origin;
};Note that in case the URL provided is invalid, this will throw. My only concern is about protocols limiting to Also noted the implementation does not support relative protocol |
||
| return /^http[s]?:\/\/\w+/.test(url); | ||
| }; | ||
|
|
||
| export const botProjectFileDispatcher = () => { | ||
| const addLocalSkill = useRecoilCallback(({ set, snapshot }: CallbackInterface) => async (skillId: string) => { | ||
|
|
@@ -52,7 +54,7 @@ export const botProjectFileDispatcher = () => { | |
| } | ||
| const botName = await snapshot.getPromise(botNameIdentifierState(skillId)); | ||
| let finalManifestUrl: string | undefined; | ||
| if (urlRegex.test(manifestUrl)) { | ||
| if (isExternalLink(manifestUrl)) { | ||
| finalManifestUrl = manifestUrl; | ||
| } else { | ||
| const data = await addSkillFiles(rootBotProjectId, botName, manifestUrl, zipContent); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,5 +40,11 @@ export const getRemoteFile = async (url): Promise<string> => { | |
|
|
||
| // convert zip folder name to skill name | ||
| export const convertFolderNameToSkillName = (path, skillName) => { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion use export const convertFolderNameToSkillName = (pathStr, skillName) => {
const folderName = path.parse(pathStr).dir;
const relativePath = path.relative(folderName, pathStr);
return path.join(skillName, relativePath);
}; |
||
| return path.replace(/(\w+)\//, `${skillName}/`); | ||
| const hasFolder = path.match(/(\w+)\//); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this doesn't allow hyphens or dashes in folder name |
||
|
|
||
| if (hasFolder === null) { | ||
| return `${skillName}/${path}`; | ||
| } | ||
|
|
||
| return path.replace(hasFolder[0], `${skillName}/`); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: put the function to utilities and reuse here and in
Composer/packages/client/src/recoilModel/dispatchers/botProjectFile.ts