File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
libraries/botframework-config Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -39,8 +39,14 @@ export class QnaMakerService extends ConnectedService implements IQnAService {
39
39
*/
40
40
constructor ( source : IQnAService = { } as IQnAService ) {
41
41
super ( source , ServiceTypes . QnA ) ;
42
+
43
+ if ( ! source . hostname ) {
44
+ throw TypeError ( 'QnAMakerService requires source parameter to have a hostname.' )
45
+ }
42
46
43
- this . hostname = new URL ( '/qnamaker' , this . hostname ) . href ;
47
+ if ( ! this . hostname . endsWith ( '/qnamaker' ) ) {
48
+ this . hostname = new URL ( '/qnamaker' , this . hostname ) . href ;
49
+ }
44
50
}
45
51
46
52
// encrypt keys in service
Original file line number Diff line number Diff line change @@ -29,5 +29,22 @@ describe("Service Tests", () => {
29
29
} ) ;
30
30
assert . equal ( qna . hostname , "https://myservice.azurewebsites.net/qnamaker" ) ;
31
31
} ) ;
32
+
33
+ it ( "QnAMaker correctly does not add suffix when already hostname endind with \/qnamaker" , ( ) => {
34
+ let qnaWithQnamakerHostname = new bf . QnaMakerService ( {
35
+ hostname : "https://MyServiceThatDoesntNeedAppending.azurewebsites.net/qnamaker"
36
+ } ) ;
37
+ assert . equal ( qnaWithQnamakerHostname . hostname , "https://MyServiceThatDoesntNeedAppending.azurewebsites.net/qnamaker" ) ;
38
+ } ) ;
39
+
40
+ it ( "QnAMaker should throw error without hostname" , ( ) => {
41
+ function createQnaWithoutHostname ( ) {
42
+ new bf . QnaMakerService ( { } ) ;
43
+ }
44
+
45
+ let noHostnameError = new TypeError ( 'QnAMakerService requires source parameter to have a hostname.' )
46
+
47
+ assert . throws ( ( ) => createQnaWithoutHostname ( ) , noHostnameError )
48
+ } ) ;
32
49
} ) ;
33
50
You can’t perform that action at this time.
0 commit comments