mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-24 00:15:17 -06:00
Fix detection of YAML and JSON files with leading whitespace
This commit is contained in:
parent
df3a5cd422
commit
c554443a6a
@ -81,12 +81,12 @@ class BulkImportForm(BootstrapMixin, SyncedDataMixin, forms.Form):
|
||||
Attempt to automatically detect the format (CSV, JSON, or YAML) of the given data, or raise
|
||||
a ValidationError.
|
||||
"""
|
||||
first_line = data.strip().split('\n', 1)[0]
|
||||
try:
|
||||
if data[0] in ('{', '['):
|
||||
if first_line[0] in ('{', '['):
|
||||
return ImportFormatChoices.JSON
|
||||
if data.startswith('---') or data.startswith('- '):
|
||||
if first_line.startswith('---') or first_line.startswith('- '):
|
||||
return ImportFormatChoices.YAML
|
||||
first_line = data.split('\n', 1)[0]
|
||||
if ',' in first_line:
|
||||
return ImportFormatChoices.CSV
|
||||
if ';' in first_line:
|
||||
|
Loading…
Reference in New Issue
Block a user