diff --git a/src/rp/detect.py b/src/rp/detect.py index e439c16..fd3dc00 100644 --- a/src/rp/detect.py +++ b/src/rp/detect.py @@ -90,10 +90,13 @@ def detect_type( return EXTENSION_MAP[suffix] if content is not None: - stripped = content.lstrip() - if stripped and stripped[0] in ("{", "["): + stripped = content.strip() + if stripped and ( + (stripped[0] == "{" and stripped[-1] == "}") + or (stripped[0] == "[" and stripped[-1] == "]") + ): try: - json.loads(stripped[:1000]) + json.loads(stripped) return "json" except (json.JSONDecodeError, ValueError): pass