Skip to content

Commit

Permalink
move regex outside
Browse files Browse the repository at this point in the history
  • Loading branch information
leo-lox committed Jan 12, 2025
1 parent 8e9a938 commit 76b64c1
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/ndk/lib/domain_layer/usecases/files/files.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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})(?:/|$)');

Check warning on line 10 in packages/ndk/lib/domain_layer/usecases/files/files.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/files/files.dart#L10

Added line #L10 was not covered by tests

Files(this.blossom);

/// upload a file to the server(s) \
Expand Down Expand Up @@ -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);

Check warning on line 53 in packages/ndk/lib/domain_layer/usecases/files/files.dart

View check run for this annotation

Codecov / codecov/patch

packages/ndk/lib/domain_layer/usecases/files/files.dart#L53

Added line #L53 was not covered by tests

if (sha256Match != null) {
// This is a blossom URL, handle it using blossom protocol
Expand Down

0 comments on commit 76b64c1

Please sign in to comment.