diff --git a/public/icons/icon-128x128.png b/public/app-icon/icon-128x128.png similarity index 100% rename from public/icons/icon-128x128.png rename to public/app-icon/icon-128x128.png diff --git a/public/icons/icon-144x144.png b/public/app-icon/icon-144x144.png similarity index 100% rename from public/icons/icon-144x144.png rename to public/app-icon/icon-144x144.png diff --git a/public/icons/icon-152x152.png b/public/app-icon/icon-152x152.png similarity index 100% rename from public/icons/icon-152x152.png rename to public/app-icon/icon-152x152.png diff --git a/public/icons/icon-192x192.png b/public/app-icon/icon-192x192.png similarity index 100% rename from public/icons/icon-192x192.png rename to public/app-icon/icon-192x192.png diff --git a/public/icons/icon-384x384.png b/public/app-icon/icon-384x384.png similarity index 100% rename from public/icons/icon-384x384.png rename to public/app-icon/icon-384x384.png diff --git a/public/icons/icon-512x512.png b/public/app-icon/icon-512x512.png similarity index 100% rename from public/icons/icon-512x512.png rename to public/app-icon/icon-512x512.png diff --git a/public/icons/icon-72x72.png b/public/app-icon/icon-72x72.png similarity index 100% rename from public/icons/icon-72x72.png rename to public/app-icon/icon-72x72.png diff --git a/public/icons/icon-96x96.png b/public/app-icon/icon-96x96.png similarity index 100% rename from public/icons/icon-96x96.png rename to public/app-icon/icon-96x96.png diff --git a/src/app/components/explore/explore.component.html b/src/app/components/explore/explore.component.html index 8c5e622..879b3b3 100644 --- a/src/app/components/explore/explore.component.html +++ b/src/app/components/explore/explore.component.html @@ -49,7 +49,7 @@
Card cover image @@ -58,7 +58,7 @@
Project logo
diff --git a/src/app/components/explore/explore.component.ts b/src/app/components/explore/explore.component.ts index 0310395..a1c2a07 100644 --- a/src/app/components/explore/explore.component.ts +++ b/src/app/components/explore/explore.component.ts @@ -20,6 +20,7 @@ import { MetadataService } from 'app/services/metadata.service'; import { Subject, takeUntil } from 'rxjs'; import { IndexedDBService } from 'app/services/indexed-db.service'; import { Project } from 'app/interface/project.interface'; +import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; @Component({ selector: 'explore', @@ -47,7 +48,8 @@ export class ExploreComponent implements OnInit, OnDestroy { private stateService: StateService, private metadataService: MetadataService, private indexedDBService: IndexedDBService, - private changeDetectorRef: ChangeDetectorRef + private changeDetectorRef: ChangeDetectorRef, + private sanitizer: DomSanitizer ) {} ngOnInit(): void { @@ -236,4 +238,19 @@ export class ExploreComponent implements OnInit, OnDestroy { this.loading = false; this.changeDetectorRef.detectChanges(); } + + getSafeUrl(url: any, isBanner: boolean): SafeUrl { + if (url && typeof url === 'string' && this.isImageUrl(url)) { + return this.sanitizer.bypassSecurityTrustUrl(url); + } else { + const defaultImage = isBanner ? '/images/pages/profile/cover.jpg' : 'images/avatars/avatar-placeholder.png'; + return this.sanitizer.bypassSecurityTrustUrl(defaultImage); + } + } + + private isImageUrl(url: string): boolean { + return /\.(jpeg|jpg|gif|png|svg|bmp|webp|tiff|ico)$/i.test(url); + } + + } diff --git a/src/app/components/profile/profile.component.html b/src/app/components/profile/profile.component.html index 72b3570..f0ce37e 100644 --- a/src/app/components/profile/profile.component.html +++ b/src/app/components/profile/profile.component.html @@ -17,7 +17,7 @@
- {{metadata?.display_name || metadata?.name || 'Avatar'}} + {{metadata?.display_name || metadata?.name || 'Avatar'}} {{metadata?.display_name || metadata?.name || 'Avatar'}} diff --git a/src/app/components/profile/profile.component.ts b/src/app/components/profile/profile.component.ts index fbc683c..2018e35 100644 --- a/src/app/components/profile/profile.component.ts +++ b/src/app/components/profile/profile.component.ts @@ -21,6 +21,7 @@ import { SignerService } from 'app/services/signer.service'; import { MetadataService } from 'app/services/metadata.service'; import { Subject, takeUntil } from 'rxjs'; import { IndexedDBService } from 'app/services/indexed-db.service'; +import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; @Component({ selector: 'profile', @@ -54,7 +55,9 @@ export class ProfileComponent implements OnInit, OnDestroy { private _changeDetectorRef: ChangeDetectorRef, private _metadataService: MetadataService, private _signerService: SignerService, - private _indexedDBService: IndexedDBService + private _indexedDBService: IndexedDBService, + private _sanitizer: DomSanitizer + ) { } ngOnInit(): void { @@ -117,4 +120,8 @@ export class ProfileComponent implements OnInit, OnDestroy { this._changeDetectorRef.detectChanges(); } } + + getSafeUrl(url: string): SafeUrl { + return this._sanitizer.bypassSecurityTrustUrl(url); + } } diff --git a/src/app/components/settings/relay/relay.component.html b/src/app/components/settings/relay/relay.component.html index 921d0a1..2df7088 100644 --- a/src/app/components/settings/relay/relay.component.html +++ b/src/app/components/settings/relay/relay.component.html @@ -19,7 +19,7 @@ class="flex h-10 w-10 flex-0 items-center justify-center overflow-hidden rounded-full" > relay avatar diff --git a/src/app/components/settings/relay/relay.component.ts b/src/app/components/settings/relay/relay.component.ts index 93979bc..6adae8c 100644 --- a/src/app/components/settings/relay/relay.component.ts +++ b/src/app/components/settings/relay/relay.component.ts @@ -14,6 +14,7 @@ import { MatFormFieldModule } from '@angular/material/form-field'; import { MatIconModule } from '@angular/material/icon'; import { MatInputModule } from '@angular/material/input'; import { MatSelectModule } from '@angular/material/select'; +import { DomSanitizer, SafeUrl } from '@angular/platform-browser'; import { RelayService } from 'app/services/relay.service'; import { Subscription } from 'rxjs'; @@ -44,7 +45,8 @@ export class SettingsRelayComponent implements OnInit { constructor( private relayService: RelayService, private cdr: ChangeDetectorRef, - private zone: NgZone + private zone: NgZone, + private sanitizer: DomSanitizer ) {} ngOnInit(): void { @@ -106,8 +108,14 @@ export class SettingsRelayComponent implements OnInit { return relay.connected ? 'Connected' : 'Disconnected'; } - relayFavIcon(url: string) { - const favUrl = url.replace('wss://', 'https://'); - return favUrl + '/favicon.ico'; - } + relayFavIcon(url: string): string { + let safeUrl = url.replace('wss://', 'https://').replace('ws://', 'https://'); + + return safeUrl + '/favicon.ico'; + } + + getSafeUrl(url: string): SafeUrl { + return this.sanitizer.bypassSecurityTrustUrl(url); + } + } diff --git a/src/app/layout/common/user/user.component.html b/src/app/layout/common/user/user.component.html index 8b1f889..2385508 100644 --- a/src/app/layout/common/user/user.component.html +++ b/src/app/layout/common/user/user.component.html @@ -1,7 +1,7 @@