Refactor regex in normalized_coordinates method to allow for whitespace between square brackets

This commit is contained in:
CoslaJohn
2024-02-09 14:36:02 +00:00
parent 614945a607
commit 81d768f1c0

View File

@@ -28,9 +28,10 @@ class Geozone < ApplicationRecord
def normalized_coordinates def normalized_coordinates
if geojson.present? if geojson.present?
if geojson.match(/"coordinates"\s*:\s*\[{4}/) if geojson.match(/"coordinates"\s*:\s*\[\s*\[\s*\[\s*\[/)
coordinates.reduce([], :concat).reduce([], :concat) coordinates.reduce([], :concat).reduce([], :concat)
elsif geojson.match(/"coordinates"\s*:\s*\[{3}/) elsif geojson.match(/"coordinates"\s*:\s*\[\s*\[\s*\[/)
coordinates.reduce([], :concat) coordinates.reduce([], :concat)
else else
coordinates coordinates