diff options
Diffstat (limited to 'src/models/Service.ts')
-rw-r--r-- | src/models/Service.ts | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/models/Service.ts b/src/models/Service.ts index 92b8ee64c..21fa65f69 100644 --- a/src/models/Service.ts +++ b/src/models/Service.ts | |||
@@ -11,6 +11,7 @@ import UserAgent from './UserAgent'; | |||
11 | import { DEFAULT_SERVICE_ORDER } from '../config'; | 11 | import { DEFAULT_SERVICE_ORDER } from '../config'; |
12 | import { ifUndefined } from '../jsUtils'; | 12 | import { ifUndefined } from '../jsUtils'; |
13 | import { IRecipe } from './Recipe'; | 13 | import { IRecipe } from './Recipe'; |
14 | import { needsToken } from '../api/apiBase'; | ||
14 | 15 | ||
15 | const debug = require('../preload-safe-debug')('Ferdium:Service'); | 16 | const debug = require('../preload-safe-debug')('Ferdium:Service'); |
16 | 17 | ||
@@ -295,6 +296,21 @@ export default class Service { | |||
295 | 296 | ||
296 | @computed get icon(): string { | 297 | @computed get icon(): string { |
297 | if (this.iconUrl) { | 298 | if (this.iconUrl) { |
299 | if (needsToken()) { | ||
300 | let url: URL; | ||
301 | try { | ||
302 | url = new URL(this.iconUrl); | ||
303 | } catch (error) { | ||
304 | debug('Invalid url', this.iconUrl, error); | ||
305 | return this.iconUrl; | ||
306 | } | ||
307 | const requestStore = (window as any).ferdium.stores.requests; | ||
308 | // Make sure we only pass the token to the local server. | ||
309 | if (url.origin === requestStore.localServerOrigin) { | ||
310 | url.searchParams.set('token', requestStore.localServerToken); | ||
311 | return url.toString(); | ||
312 | } | ||
313 | } | ||
298 | return this.iconUrl; | 314 | return this.iconUrl; |
299 | } | 315 | } |
300 | 316 | ||