Skip to content

Commit

Permalink
Fix null access on trim
Browse files Browse the repository at this point in the history
  • Loading branch information
felixbrucker committed Dec 26, 2023
1 parent 6b55ad5 commit 60adf31
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/app/update-account/update-account.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export class UpdateAccountComponent {

public get newImageUrl(): string|undefined {
const value = this.imageUrlForm.controls['imageUrl'].getRawValue()
if (value === null || value === undefined) {
return undefined
}
const trimmedValue = value.trim()

return value?.trim() === '' ? undefined : value.trim()
return trimmedValue === '' ? undefined : trimmedValue
}

constructor(
Expand Down Expand Up @@ -115,9 +119,12 @@ export class UpdateAccountComponent {
)
}

private async isValidImageUrl(imageUrl: string|undefined): Promise<boolean> {
imageUrl = imageUrl?.trim() === '' ? undefined : imageUrl.trim()
if (imageUrl === undefined) {
private async isValidImageUrl(imageUrl: string|null|undefined): Promise<boolean> {
if (imageUrl === null || imageUrl === undefined) {
return true
}
imageUrl = imageUrl.trim()
if (imageUrl === '') {
return true
}

Expand Down

0 comments on commit 60adf31

Please sign in to comment.