@@ -83,17 +83,11 @@ export const getAppHref = (
83
83
: app . url ;
84
84
}
85
85
86
- // The backend redirects if the trailing slash isn't included, so we add it
87
- // here to avoid extra roundtrips.
88
- let href = `${ path } /@${ workspace . owner_name } /${ workspace . name } .${
89
- agent . name
90
- } /apps/${ encodeURIComponent ( app . slug ) } /`;
91
-
92
86
if ( app . command ) {
93
87
// Terminal links are relative. The terminal page knows how
94
88
// to select the correct workspace proxy for the websocket
95
89
// connection.
96
- href = `/@${ workspace . owner_name } /${ workspace . name } .${
90
+ return `/@${ workspace . owner_name } /${ workspace . name } .${
97
91
agent . name
98
92
} /terminal?command=${ encodeURIComponent ( app . command ) } `;
99
93
}
@@ -102,23 +96,14 @@ export const getAppHref = (
102
96
const baseUrl = `${ window . location . protocol } //${ host . replace ( / \* / g, app . subdomain_name ) } ` ;
103
97
const url = new URL ( baseUrl ) ;
104
98
url . pathname = "/" ;
105
- href = url . toString ( ) ;
106
- }
107
-
108
- return href ;
109
- } ;
110
-
111
- export const needsSessionToken = ( app : WorkspaceApp ) => {
112
- if ( ! isExternalApp ( app ) ) {
113
- return false ;
99
+ return url . toString ( ) ;
114
100
}
115
101
116
- // HTTP links should never need the session token, since Cookies
117
- // handle sharing it when you access the Coder Dashboard. We should
118
- // never be forwarding the bare session token to other domains!
119
- const isHttp = app . url . startsWith ( "http" ) ;
120
- const requiresSessionToken = app . url . includes ( SESSION_TOKEN_PLACEHOLDER ) ;
121
- return requiresSessionToken && ! isHttp ;
102
+ // The backend redirects if the trailing slash isn't included, so we add it
103
+ // here to avoid extra roundtrips.
104
+ return `${ path } /@${ workspace . owner_name } /${ workspace . name } .${
105
+ agent . name
106
+ } /apps/${ encodeURIComponent ( app . slug ) } /`;
122
107
} ;
123
108
124
109
type ExternalWorkspaceApp = WorkspaceApp & {
@@ -131,3 +116,12 @@ export const isExternalApp = (
131
116
) : app is ExternalWorkspaceApp => {
132
117
return app . external && app . url !== undefined ;
133
118
} ;
119
+
120
+ export const needsSessionToken = ( app : ExternalWorkspaceApp ) => {
121
+ // HTTP links should never need the session token, since Cookies
122
+ // handle sharing it when you access the Coder Dashboard. We should
123
+ // never be forwarding the bare session token to other domains!
124
+ const isHttp = app . url . startsWith ( "http" ) ;
125
+ const requiresSessionToken = app . url . includes ( SESSION_TOKEN_PLACEHOLDER ) ;
126
+ return requiresSessionToken && ! isHttp ;
127
+ } ;
0 commit comments