From 959b494b128f3a37107194f356a9b2463a94bc27 Mon Sep 17 00:00:00 2001 From: Thomas Fransolet Date: Wed, 9 Jul 2025 14:48:36 +0200 Subject: [PATCH] Support also mymuseum url --- lib/Components/ScannerDialog.dart | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/lib/Components/ScannerDialog.dart b/lib/Components/ScannerDialog.dart index 02c4593..18ed74e 100644 --- a/lib/Components/ScannerDialog.dart +++ b/lib/Components/ScannerDialog.dart @@ -100,13 +100,25 @@ class _ScannerDialogState extends State { if (barcode.format == BarcodeFormat.qrCode && code.isNotEmpty) { isProcessing = true; - RegExp regExp = RegExp(r'^(?:https:\/\/web\.mymuseum\.be\/([^\/]+)\/([^\/]+)\/([^\/]+)|([^\/]+))$'); // myinfomate + RegExp regExp = RegExp(r'^(?:https:\/\/web\.myinfomate\.be\/([^\/]+)\/([^\/]+)\/([^\/]+)|([^\/]+))$'); // myinfomate + RegExp regExp2 = RegExp(r'^(?:https:\/\/web\.mymuseum\.be\/([^\/]+)\/([^\/]+)\/([^\/]+)|([^\/]+))$'); // myinfomate var match = regExp.firstMatch(code); - String? instanceId = match?.group(1); - String? configurationId = match?.group(2); - String? sectionId = match?.group(3) ?? match?.group(4); + var match2 = regExp2.firstMatch(code); + String? instanceId; + String? configurationId; + String? sectionId; - if (match == null || sectionId == null) { + if(match == null) { + instanceId = match2?.group(1); + configurationId = match2?.group(2); + sectionId = match2?.group(3) ?? match2?.group(4); + } else { + instanceId = match.group(1); + configurationId = match.group(2); + sectionId = match.group(3) ?? match.group(4); + } + + if ((match == null && match2 == null) || sectionId == null) { ScaffoldMessenger.of(context).showSnackBar( SnackBar(content: Text("L'URL ne correspond pas au format attendu."), backgroundColor: kMainColor2), );