Skip to content

Commit

Permalink
Fix issue that unnecessary semicolons being added to the address of t…
Browse files Browse the repository at this point in the history
…he vcf when the addAddress method parameters has empty or null #60
  • Loading branch information
Janith-Umeda committed Jan 28, 2025
1 parent 36f975a commit 1f43027
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/VCard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,12 @@ export default class VCard {
country: string = '',
type: string = 'WORK;POSTAL',
): this {
const value = `\
${name};${extended};${street};${city};${region};${zip};${country}\
`
const value = [name, extended, street, city, region, zip, country]
.filter((part) => part !== null && part !== '')
.join(';')

if (value === '') return this

this.setProperty(
'address',
`ADR${type !== '' ? `;${type}` : ''}${this.getCharsetString()}`,
Expand Down

0 comments on commit 1f43027

Please sign in to comment.