diff --git a/index.js b/index.js index 66c8d16..287c5a6 100644 --- a/index.js +++ b/index.js @@ -82,6 +82,6 @@ function normalize (unknown) { if (!unknown) throw new Error('Value must not be null or undefined.') if (Array.isArray(unknown)) return fromCoordinates(unknown) else if (typeof unknown === 'string') return fromString(unknown) - else if (unknown.x && unknown.y) return fromPoint(unknown) + else if ((unknown.x || unknown.x === 0) && (unknown.y || unknown.y === 0)) return fromPoint(unknown) return floatize(unknown) } diff --git a/index.test.js b/index.test.js index f233ff6..52428fc 100644 --- a/index.test.js +++ b/index.test.js @@ -127,6 +127,7 @@ describe('lonlat', () => { describe('issues', () => { it('#3 - Does not parse coordinates with 0 for lat or lon', () => { expect(ll({ lat: 0, lng: 0 })).toEqual({ lat: 0, lon: 0 }) + expect(ll({ x: 0, y: 0 })).toEqual({ lat: 0, lon: 0 }) }) }) })