Skip to content

Commit

Permalink
Parse facebook profile id urls
Browse files Browse the repository at this point in the history
  • Loading branch information
Zverik committed Sep 22, 2024
1 parent b51289e commit eaadd30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 6 additions & 4 deletions lib/fields/helpers/qr_code.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class QrCodeScanner extends StatefulWidget {
class _QrCodeScannerState extends State<QrCodeScanner> {
static final _logger = Logger('QrCodeScanner');

bool done = false;
String? _scannedLast;

Future<Uri> _resolveRedirects(Uri uri, [int depth = 0]) async {
final client = http.Client();
Expand Down Expand Up @@ -66,9 +66,12 @@ class _QrCodeScannerState extends State<QrCodeScanner> {
),
body: MobileScanner(
onDetect: (codes) async {
if (!done && mounted && codes.barcodes.isNotEmpty) {
final code = codes.barcodes.first;
if (code.rawValue != _scannedLast && mounted && codes.barcodes.isNotEmpty) {
// we need this because it scans twice sometimes
_scannedLast = code.rawValue;

final nav = Navigator.of(context);
final code = codes.barcodes.first;
String? url;
if (code.type == BarcodeType.url) {
url = code.url?.url;
Expand All @@ -84,7 +87,6 @@ class _QrCodeScannerState extends State<QrCodeScanner> {
}

if (url != null) {
done = true; // we need this because it scans twice sometimes
if (mounted) nav.pop(url);
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/fields/helpers/website_fmt.dart
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,9 @@ class FacebookProvider extends _ProviderHelper {
prefixes: ['fb', 'facebook', 'face'],
key: 'contact:facebook',
regexp: RegExp(
r'(?:facebook(?:\.com)?/)?((?:groups/)?[^/? ]+)/?(?:\?.*)?$'),
regexpUrl: RegExp(r'facebook\.com/((?:groups/)?[^/? ]+)/?(?:\?.*)?$'),
r'(?:facebook(?:\.com)?/)?((?:groups/|people/)?[^/? ]+(?:/[0-9]{8,})?)/?(?:\?.*)?$'),
regexpUrl: RegExp(
r'facebook\.com/((?:groups|people/)?[^/? ]+(?:/[0-9]{8,})?)/?(?:\?.*)?$'),
format: 'https://www.facebook.com/%s/',
);
}
Expand Down

0 comments on commit eaadd30

Please sign in to comment.