Skip to content

Conversation

Nick59
Copy link
Contributor

@Nick59 Nick59 commented Apr 3, 2020

Hi !

I'm working with this great tool and i have a very small suggestions to do to make it better :)

I'm working with Mapbox API and i need the country short code which is not parsed in property list.

@Nick59 Nick59 mentioned this pull request Apr 3, 2020
Copy link
Collaborator

@simon04 simon04 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR. I found a small issue in your patch. Please address it...

properties[id] = loc.context[j].text;

// Get country code when available
if (loc.context[j].short_code != 'undefined') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use one of the following variants (yours does not detect undefined correctly):

  1. if (typeof loc.context[j].short_code !== 'undefined')
  2. if (loc.context[j].short_code !== undefined)
  3. if (loc.context[j].short_code)

I prefer variant 3.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it ! I always struggle with those 'undefined' in JS..

@Nick59 Nick59 force-pushed the mapbox-country-code branch from 16f1db8 to de5691a Compare April 4, 2020 13:33
@simon04 simon04 merged commit 302cf85 into perliedman:master Apr 4, 2020
@Nick59 Nick59 deleted the mapbox-country-code branch April 6, 2020 17:07
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.

2 participants