Skip to content

Commit 0564148

Browse files
committed
fix(parsing): allow parsing coordinate at 0,0 with x,y object input
1 parent 3d38053 commit 0564148

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,6 @@ function normalize (unknown) {
8282
if (!unknown) throw new Error('Value must not be null or undefined.')
8383
if (Array.isArray(unknown)) return fromCoordinates(unknown)
8484
else if (typeof unknown === 'string') return fromString(unknown)
85-
else if (unknown.x && unknown.y) return fromPoint(unknown)
85+
else if ((unknown.x || unknown.x === 0) && (unknown.y || unknown.y === 0)) return fromPoint(unknown)
8686
return floatize(unknown)
8787
}

index.test.js

+1
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ describe('lonlat', () => {
127127
describe('issues', () => {
128128
it('#3 - Does not parse coordinates with 0 for lat or lon', () => {
129129
expect(ll({ lat: 0, lng: 0 })).toEqual({ lat: 0, lon: 0 })
130+
expect(ll({ x: 0, y: 0 })).toEqual({ lat: 0, lon: 0 })
130131
})
131132
})
132133
})

0 commit comments

Comments
 (0)