Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue that unnecessary semicolons being added to the address of t… #61

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Janith-Umeda
Copy link

@Janith-Umeda Janith-Umeda commented Jan 27, 2025

…he vcf when the addAddress method parameters has empty or null (#60)

Request type

  • Chore
  • Feature
  • Fix
  • Refactor
  • Tests
  • Documentation

Summary

Fix issue that unnecessary semicolons being added to the address of the vcf when the addAddress method parameters has empty or null

Change description

As you can see in the screenshot below, there is 'null' and unnecessary ';' characters appears when the addAddress method's args has null values.

like this ⬇

.addAddress(
    'name',
    'extended',
    null,
    'worktown',
    'state',
    undefined,
    'Belgium',
)

Image

So i've fixed this issue by pushing all parameters to an array and then filter good values among them and join them to one string with ';'.

  public addAddress(
    name: string = '',
    extended: string = '',
    street: string = '',
    city: string = '',
    region: string = '',
    zip: string = '',
    country: string = '',
    type: string = 'WORK;POSTAL',
  ): this {
    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()}`,
      value,
    )

    return this
  }

Image

Check lists

  • Tests passed
  • Coding style respected

…he vcf when the addAddress method parameters has empty or null joaocarmo#60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant