File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -66,7 +66,11 @@ export class AuthUtil {
66
66
} else {
67
67
this . usingEnterpriseSSO = false
68
68
}
69
- TelemetryHelper . instance . startUrl = isSsoConnection ( this . conn ) ? this . conn ?. startUrl : undefined
69
+ // Reformat the url to remove any trailing '/' and `#`
70
+ // e.g. https://view.awsapps.com/start/# will become https://view.awsapps.com/start
71
+ TelemetryHelper . instance . startUrl = isSsoConnection ( this . conn )
72
+ ? this . reformatStartUrl ( this . conn ?. startUrl )
73
+ : undefined
70
74
await Promise . all ( [
71
75
vscode . commands . executeCommand ( 'aws.codeWhisperer.refresh' ) ,
72
76
vscode . commands . executeCommand ( 'aws.codeWhisperer.refreshRootNode' ) ,
@@ -78,6 +82,10 @@ export class AuthUtil {
78
82
} )
79
83
}
80
84
85
+ public reformatStartUrl ( startUrl : string | undefined ) {
86
+ return ! startUrl ? undefined : startUrl . replace ( / [ \/ # ] + $ / g, '' )
87
+ }
88
+
81
89
// current active cwspr connection
82
90
public get conn ( ) {
83
91
return this . secondaryAuth . activeConnection
Original file line number Diff line number Diff line change @@ -134,4 +134,14 @@ describe('AuthUtil', async function () {
134
134
assert . strictEqual ( authUtil . conn . ssoRegion , upgradeableConn . ssoRegion )
135
135
assert . strictEqual ( ( await auth . listConnections ( ) ) . filter ( isSsoConnection ) . length , 1 )
136
136
} )
137
+
138
+ it ( 'test reformatStartUrl should remove trailing slash and hash' , function ( ) {
139
+ const expected = 'https://view.awsapps.com/start'
140
+ assert . strictEqual ( authUtil . reformatStartUrl ( expected + '/' ) , expected )
141
+ assert . strictEqual ( authUtil . reformatStartUrl ( undefined ) , undefined )
142
+ assert . strictEqual ( authUtil . reformatStartUrl ( expected + '/#' ) , expected )
143
+ assert . strictEqual ( authUtil . reformatStartUrl ( expected + '#/' ) , expected )
144
+ assert . strictEqual ( authUtil . reformatStartUrl ( expected + '/#/' ) , expected )
145
+ assert . strictEqual ( authUtil . reformatStartUrl ( expected + '####' ) , expected )
146
+ } )
137
147
} )
You can’t perform that action at this time.
0 commit comments