From 76b64c1dd11e7e34ed3d72e86f10527c7a6b6a35 Mon Sep 17 00:00:00 2001 From: LeoLox <58687994+leo-lox@users.noreply.github.com> Date: Sun, 12 Jan 2025 17:16:16 +0100 Subject: [PATCH] move regex outside --- packages/ndk/lib/domain_layer/usecases/files/files.dart | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/ndk/lib/domain_layer/usecases/files/files.dart b/packages/ndk/lib/domain_layer/usecases/files/files.dart index 4a96ff1f..31d3d8ab 100644 --- a/packages/ndk/lib/domain_layer/usecases/files/files.dart +++ b/packages/ndk/lib/domain_layer/usecases/files/files.dart @@ -6,6 +6,9 @@ import 'blossom.dart'; class Files { final Blossom blossom; + /// Regular expression to match SHA256 in URLs + static final sha256Regex = RegExp(r'/([a-fA-F0-9]{64})(?:/|$)'); + Files(this.blossom); /// upload a file to the server(s) \ @@ -47,7 +50,7 @@ class Files { String? pubkey, ) async { // Regular expression to match SHA256 in URLs - final sha256Match = RegExp(r'/([a-fA-F0-9]{64})(?:/|$)').firstMatch(url); + final sha256Match = sha256Regex.firstMatch(url); if (sha256Match != null) { // This is a blossom URL, handle it using blossom protocol