deriveSlug static method
Derive a short-code slug. If the original FDL short link is known we reuse its path so existing printed/QR/deep-linked URLs keep the same suffix; otherwise we deterministically derive one from the index so re-runs are stable.
Implementation
static String deriveSlug(Map<String, dynamic> fdl, int index) {
final shortLink = fdl['shortLink'] as String?;
if (shortLink != null) {
try {
final p = Uri.parse(shortLink).path.replaceFirst(RegExp(r'^/+'), '');
if (p.isNotEmpty) return p;
} catch (_) {
// fall through
}
}
return 'imported-${index + 1}';
}