@@ -290,20 +290,17 @@ func (r Request) getDatabase(ctx context.Context, db database.Store) (*databaseR
290
290
agentNameOrID = r .AgentNameOrID
291
291
appURL string
292
292
appSharingLevel database.AppSharingLevel
293
- portUint , portUintErr = strconv . ParseUint (r .AppSlugOrPort , 10 , 16 )
294
- protocol = "http"
293
+ potentialPortStr = strings . TrimSuffix (r .AppSlugOrPort , "s" )
294
+ portUint , portUintErr = strconv . ParseUint ( potentialPortStr , 10 , 16 )
295
295
)
296
- // If we fail to parse the port, see if it's a port with a trailing "s" for
297
- // HTTPS.
298
- if portUintErr != nil && strings .HasSuffix (r .AppSlugOrPort , "s" ) {
299
- appSlugOrPort := strings .TrimRight (r .AppSlugOrPort , "s" )
300
- portUint , portUintErr = strconv .ParseUint (appSlugOrPort , 10 , 16 )
301
- if portUintErr == nil {
296
+ if portUintErr == nil {
297
+ // If we fail to parse the port, see if it's a port with a trailing "s" for
298
+ // HTTPS.
299
+ protocol := "http"
300
+ if strings .HasSuffix (r .AppSlugOrPort , "s" ) {
302
301
protocol = "https"
303
302
}
304
- }
305
303
306
- if portUintErr == nil {
307
304
if r .AccessMethod != AccessMethodSubdomain {
308
305
// TODO(@deansheather): this should return a 400 instead of a 500.
309
306
return nil , xerrors .New ("port-based URLs are only supported for subdomain-based applications" )
0 commit comments