Commit 7227acc 1 parent 8617e5b commit 7227acc Copy full SHA for 7227acc
File tree 3 files changed +16
-11
lines changed
3 files changed +16
-11
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,9 @@ Disable masking of user input; use with problematic terminals.
48
48
49
49
OAuth client secret of personal connected app?
50
50
51
- # invalidInstanceUrl
51
+ # lightningInstanceUrl
52
52
53
- Invalid instance URL. Specify a Salesforce instance URL using the format < domainname >.salesforce.com
53
+ Invalid instance URL. It should NOT be a lightning domain.
54
54
55
55
# accessTokenStdin
56
56
Original file line number Diff line number Diff line change @@ -14,9 +14,7 @@ export class Common {
14
14
public static async resolveLoginUrl ( instanceUrl ?: string ) : Promise < string > {
15
15
const logger = await Logger . child ( 'Common' , { tag : 'resolveLoginUrl' } ) ;
16
16
if ( instanceUrl ) {
17
- if ( instanceUrl . match ( / l i g h t n i n g \. .* f o r c e \. c o m / ) ) {
18
- throw new SfError ( messages . getMessage ( 'invalidInstanceUrl' ) , 'URL_WARNING' ) ;
19
- }
17
+ throwIfLightning ( instanceUrl ) ;
20
18
return instanceUrl ;
21
19
}
22
20
let loginUrl : string ;
@@ -29,10 +27,17 @@ export class Common {
29
27
logger . debug ( `error occurred while trying to determine loginUrl: ${ message } ` ) ;
30
28
loginUrl = SfdcUrl . PRODUCTION ;
31
29
}
32
- if ( loginUrl . match ( / l i g h t n i n g \. .* f o r c e \. c o m / ) ) {
33
- throw new SfError ( messages . getMessage ( 'invalidInstanceUrl' ) , 'URL_WARNING' ) ;
34
- }
30
+ throwIfLightning ( loginUrl ) ;
31
+
35
32
logger . debug ( `loginUrl: ${ loginUrl } ` ) ;
36
33
return loginUrl ;
37
34
}
38
35
}
36
+
37
+ const throwIfLightning = ( urlString ?: string ) : void => {
38
+ if ( urlString ?. match ( / l i g h t n i n g \. .* f o r c e \. c o m / ) ) {
39
+ throw new SfError ( messages . getMessage ( 'lightningInstanceUrl' ) , 'LightningDomain' , [
40
+ messages . getMessage ( 'flags.instance-url.description' ) ,
41
+ ] ) ;
42
+ }
43
+ } ;
Original file line number Diff line number Diff line change @@ -77,7 +77,7 @@ describe('common unit tests', () => {
77
77
expect . fail ( 'This test is failing because it is expecting an error that is never thrown' ) ;
78
78
} catch ( error ) {
79
79
assert ( error instanceof Error ) ;
80
- expect ( error . name ) . to . equal ( 'URL_WARNING ' ) ;
80
+ expect ( error . name ) . to . equal ( 'LightningDomain ' ) ;
81
81
}
82
82
} ) ;
83
83
it ( 'should throw on lightning login URL passed in to resolveLoginUrl()' , async ( ) => {
@@ -87,7 +87,7 @@ describe('common unit tests', () => {
87
87
expect . fail ( 'This test is failing because it is expecting an error that is never thrown' ) ;
88
88
} catch ( error ) {
89
89
assert ( error instanceof Error ) ;
90
- expect ( error . name ) . to . equal ( 'URL_WARNING ' ) ;
90
+ expect ( error . name ) . to . equal ( 'LightningDomain ' ) ;
91
91
}
92
92
} ) ;
93
93
@@ -98,7 +98,7 @@ describe('common unit tests', () => {
98
98
expect . fail ( 'This test is failing because it is expecting an error that is never thrown' ) ;
99
99
} catch ( error ) {
100
100
assert ( error instanceof Error ) ;
101
- expect ( error . name ) . to . equal ( 'URL_WARNING ' ) ;
101
+ expect ( error . name ) . to . equal ( 'LightningDomain ' ) ;
102
102
}
103
103
} ) ;
104
104
} ) ;
You can’t perform that action at this time.
0 commit comments