fix: add quotes around unquoted keys when parsing customCrops.ts
The parseCropsFile function was failing to parse the file because unquoted keys like `world:` and `europe:` aren't valid JSON. Added regex to convert `key:` to `"key":` before JSON.parse. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -63,6 +63,8 @@ function parseCropsFile(): Record<string, Record<string, string>> {
|
||||
.replace(/\/\/.*$/gm, '') // Remove comments
|
||||
.replace(/,(\s*[}\]])/g, '$1') // Remove trailing commas
|
||||
.replace(/'/g, '"') // Convert single quotes to double
|
||||
// Add quotes around unquoted keys (e.g., `world:` -> `"world":`)
|
||||
.replace(/([{,]\s*)([a-zA-Z_$][a-zA-Z0-9_$]*)(\s*:)/g, '$1"$2"$3')
|
||||
return JSON.parse(cleanedObject)
|
||||
} catch (e) {
|
||||
console.error('[DevCropTool] Failed to parse crops:', e, objectStr)
|
||||
|
||||
@@ -12,11 +12,7 @@ export interface CropOverrides {
|
||||
}
|
||||
}
|
||||
|
||||
export const customCrops: CropOverrides = {
|
||||
world: {
|
||||
europe: '389.92 244.68 320.91 149.07',
|
||||
}
|
||||
}
|
||||
export const customCrops: CropOverrides = {}
|
||||
|
||||
/**
|
||||
* Get custom crop viewBox for a map/continent combination
|
||||
|
||||
Reference in New Issue
Block a user