Skip to content

Commit

Permalink
Chore (URL): CNX-9018 Do not add model from multi model urls
Browse files Browse the repository at this point in the history
- warn user and return
- otherwise add
  • Loading branch information
oguzhankoral authored Feb 29, 2024
1 parent 71071f8 commit d047f5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 7 additions & 0 deletions ui/src/components/dialogs/CreateStreamDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,13 @@ export default {
async getStream(){
try {
const streamWrapper = new StreamWrapper(this.createStreamByIdText, this.accountId, this.serverUrl)
const match = streamWrapper.matchUrl(this.createStreamByIdText)
if (match.groups.additionalModels !== undefined){
this.$eventHub.$emit('error', {
text: 'Multi-model URLs are not supported!\nTry to select just one single model in the web app and paste that in.',
})
return
}
let res = await this.$apollo.query({
query: gql`
query Stream($id: String!){
Expand Down
8 changes: 6 additions & 2 deletions ui/src/utils/streamWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,13 @@ export class StreamWrapper {
}
}

checkIsFE2(streamUrl){
matchUrl(streamUrl){
const fe2UrlRegex = /\/projects\/(?<projectId>[\w\d]+)(?:\/models\/(?<model>[\w\d]+(?:@[\w\d]+)?)(?:,(?<additionalModels>[\w\d]+(?:@[\w\d]+)?))*)?/
const match = fe2UrlRegex.exec(streamUrl);
return fe2UrlRegex.exec(streamUrl);
}

checkIsFE2(streamUrl){
const match = this.matchUrl(streamUrl)
return match !== null;
}

Expand Down

0 comments on commit d047f5e

Please sign in to comment.