From c0c678c7357f5ed5f013100afcaf8e5536de5737 Mon Sep 17 00:00:00 2001 From: Foti Dim Date: Mon, 15 Jul 2024 11:53:00 +0200 Subject: [PATCH] Trim spaces in UUIDs --- CHANGELOG.md | 3 +++ lib/src/models/ble_uuid_parser.dart | 1 + pubspec.yaml | 2 +- test/ble_uuid_parser_test.dart | 7 +++++++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0491197..926ca46 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.11.1 +* Trim spaces in UUIDs + ## 0.11.0 * Unify UUID format across all platforms, 128-bit lowercase * Add BleUuidParser utility methods for UUID parsing diff --git a/lib/src/models/ble_uuid_parser.dart b/lib/src/models/ble_uuid_parser.dart index 663f065..be775f5 100644 --- a/lib/src/models/ble_uuid_parser.dart +++ b/lib/src/models/ble_uuid_parser.dart @@ -4,6 +4,7 @@ class BleUuidParser { /// Parse a string to a valid 128-bit UUID. /// Throws `FormatException` if the string does not hold a valid UUID format. static String string(String uuid) { + uuid = uuid.trim(); if (uuid.length < 4) { throw const FormatException('Invalid UUID'); } diff --git a/pubspec.yaml b/pubspec.yaml index c889613..4df0c27 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: universal_ble description: A cross-platform (Android/iOS/macOS/Windows/Linux/Web) Bluetooth Low Energy (BLE) plugin for Flutter -version: 0.11.0 +version: 0.11.1 homepage: https://navideck.com repository: https://github.com/Navideck/universal_ble issue_tracker: https://github.com/Navideck/universal_ble/issues diff --git a/test/ble_uuid_parser_test.dart b/test/ble_uuid_parser_test.dart index 50d8612..2cdbb79 100644 --- a/test/ble_uuid_parser_test.dart +++ b/test/ble_uuid_parser_test.dart @@ -59,6 +59,13 @@ void main() { equals('0000180a-0000-1000-8000-00805f9b34fb'), ); }); + + test('128-bit UUID with trailing space', () { + expect( + BleUuidParser.string('0000180a-0000-1000-8000-00805f9b34fb '), + equals('0000180a-0000-1000-8000-00805f9b34fb'), + ); + }); }); group('Fails', () { test('Invalid UUID length is less than 4', () {