aboutsummaryrefslogtreecommitdiffstats
path: root/src/models/Service.ts
diff options
context:
space:
mode:
authorLibravatar Kristóf Marussy <kristof@marussy.com>2022-07-10 16:07:45 +0200
committerLibravatar Kristóf Marussy <kristof@marussy.com>2022-07-11 17:47:53 +0200
commitfa1a7037b47f2e0114d8abc5a99d29239bd3637b (patch)
tree83404acf711aa8976dce47950edcca64836e0cd8 /src/models/Service.ts
parent6.0.0-nightly.96 [skip ci] (diff)
downloadferdium-app-fa1a7037b47f2e0114d8abc5a99d29239bd3637b.tar.gz
ferdium-app-fa1a7037b47f2e0114d8abc5a99d29239bd3637b.tar.zst
ferdium-app-fa1a7037b47f2e0114d8abc5a99d29239bd3637b.zip
refactor: local server import/export
Signed-off-by: Kristóf Marussy <kristof@marussy.com>
Diffstat (limited to 'src/models/Service.ts')
-rw-r--r--src/models/Service.ts16
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';
11import { DEFAULT_SERVICE_ORDER } from '../config'; 11import { DEFAULT_SERVICE_ORDER } from '../config';
12import { ifUndefined } from '../jsUtils'; 12import { ifUndefined } from '../jsUtils';
13import { IRecipe } from './Recipe'; 13import { IRecipe } from './Recipe';
14import { needsToken } from '../api/apiBase';
14 15
15const debug = require('../preload-safe-debug')('Ferdium:Service'); 16const 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