From 2709a70225e0369c310c0e0d71730fa3448556d7 Mon Sep 17 00:00:00 2001 From: Lauri Svan Date: Fri, 10 May 2024 17:32:11 +0300 Subject: [PATCH] Avoid unnecessary null pointer exception if reference schema is given --- lib/src/json_schema/json_schema.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/src/json_schema/json_schema.dart b/lib/src/json_schema/json_schema.dart index 7c92d06d..c8cc02f4 100644 --- a/lib/src/json_schema/json_schema.dart +++ b/lib/src/json_schema/json_schema.dart @@ -305,7 +305,10 @@ class JsonSchema { _customFormats = customFormats; _rootMemomizedPathResults = {}; try { - _fetchedFromUriBase = JsonSchemaUtils.getBaseFromFullUri(_fetchedFromUri!); + // Only fetch the base if given + if (_fetchedFromUri != null) { + _fetchedFromUriBase = JsonSchemaUtils.getBaseFromFullUri(_fetchedFromUri!); + } } catch (e) { // ID base can't be set for schemes other than HTTP(S). // This is expected behavior.