From 65c66f14e7350ddaa6e75f38708cf9db0bc59847 Mon Sep 17 00:00:00 2001 From: Nikolas Rimikis Date: Sun, 19 Nov 2023 12:03:50 +0100 Subject: [PATCH] refactor(nextcloud): cleanup WebDavOptions Signed-off-by: Nikolas Rimikis --- packages/nextcloud/lib/src/webdav/client.dart | 16 +++++++++------- packages/nextcloud/lib/src/webdav/webdav.dart | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/nextcloud/lib/src/webdav/client.dart b/packages/nextcloud/lib/src/webdav/client.dart index e183cdaf..b9ba4bd0 100644 --- a/packages/nextcloud/lib/src/webdav/client.dart +++ b/packages/nextcloud/lib/src/webdav/client.dart @@ -93,11 +93,12 @@ class WebDavClient { 'OPTIONS', _constructUri(), ); - final davCapabilities = response.headers['dav']?.first ?? ''; - final davSearchCapabilities = response.headers['dasl']?.first ?? ''; + + final davCapabilities = response.headers['dav']?.first; + final davSearchCapabilities = response.headers['dasl']?.first; return WebDavOptions( - davCapabilities.split(',').map((final e) => e.trim()).where((final e) => e.isNotEmpty).toSet(), - davSearchCapabilities.split(',').map((final e) => e.trim()).where((final e) => e.isNotEmpty).toSet(), + davCapabilities?.split(',').map((final e) => e.trim()).where((final e) => e.isNotEmpty).toSet(), + davSearchCapabilities?.split(',').map((final e) => e.trim()).where((final e) => e.isNotEmpty).toSet(), ); } @@ -347,9 +348,10 @@ class WebDavClient { class WebDavOptions { /// Creates a new WebDavStatus. WebDavOptions( - this.capabilities, - this.searchCapabilities, - ); + final Set? capabilities, + final Set? searchCapabilities, + ) : capabilities = capabilities ?? {}, + searchCapabilities = searchCapabilities ?? {}; /// DAV capabilities as advertised by the server in the 'dav' header. Set capabilities; diff --git a/packages/nextcloud/lib/src/webdav/webdav.dart b/packages/nextcloud/lib/src/webdav/webdav.dart index 664cdb7d..4bdc006f 100644 --- a/packages/nextcloud/lib/src/webdav/webdav.dart +++ b/packages/nextcloud/lib/src/webdav/webdav.dart @@ -17,7 +17,7 @@ const namespaceNextcloud = 'http://nextcloud.org/ns'; const namespaceOpenCollaborationServices = 'http://open-collaboration-services.org/ns'; const namespaceOpenCloudMesh = 'http://open-cloud-mesh.org/ns'; -final Map namespaces = { +const Map namespaces = { namespaceDav: 'd', namespaceOwncloud: 'oc', namespaceNextcloud: 'nc',