27 lines
888 B
Dart
27 lines
888 B
Dart
// Deep links (SPEC.md §3): the OS hands the app a URI a QR scanner or a
|
|
// browser produced. Only the smol scheme is ours to interpret, and the
|
|
// native parser decides validity — fumi rejects a smol:// URI without its
|
|
// key, so every link that parses is the self-certifying form.
|
|
|
|
import "package:smol_mail/smol/address.dart";
|
|
import "package:smol_mail/smol/errors.dart";
|
|
|
|
class SmolLink {
|
|
final SmolAddress address;
|
|
final String source;
|
|
|
|
const SmolLink._(this.address, this.source);
|
|
}
|
|
|
|
/// Parses a smol:// URI. Returns null for other schemes and for anything
|
|
/// the native parser rejects — those are not silent fixes, they are not
|
|
/// for this app to act on.
|
|
SmolLink? parseSmolLink(String uri) {
|
|
final text = uri.trim();
|
|
if (!text.startsWith("smol://")) return null;
|
|
try {
|
|
return SmolLink._(parseAddress(text), text);
|
|
} on SmolError {
|
|
return null;
|
|
}
|
|
}
|