mirror of
https://gitlab.com/TheOneWithTheBraid/dart_pkpass.git
synced 2025-07-06 13:28:48 +00:00
fix: support compressed archives and advanced character encoding
Signed-off-by: The one with the braid <info@braid.business>
This commit is contained in:
parent
6e34b5220c
commit
0863580b23
4 changed files with 70 additions and 33 deletions
|
@ -12,7 +12,12 @@ abstract class FileMatcher {
|
|||
}) {
|
||||
final localized = matchLocale(files: files, name: 'logo', extension: 'png');
|
||||
if (localized.isEmpty) return null;
|
||||
final scaled = matchScale(files: localized, name: 'logo', extension: 'png', scale: scale);
|
||||
final scaled = matchScale(
|
||||
files: localized,
|
||||
name: 'logo',
|
||||
extension: 'png',
|
||||
scale: scale,
|
||||
);
|
||||
final file = files.singleWhere((element) => element == scaled);
|
||||
return file;
|
||||
}
|
||||
|
@ -23,17 +28,28 @@ abstract class FileMatcher {
|
|||
required String name,
|
||||
required String extension,
|
||||
}) {
|
||||
files.sort();
|
||||
files.sort((a, b) {
|
||||
final aLocalized = a.startsWith(RegExp('^[a-z]+(-[a-z]+)?\\.lproj\\/'));
|
||||
final bLocalized = b.startsWith(RegExp('^[a-z]+(-[a-z]+)?\\.lproj\\/'));
|
||||
if (aLocalized && bLocalized) {
|
||||
return a.compareTo(b);
|
||||
} else if (aLocalized) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
files = files.reversed.toList();
|
||||
List<RegExp> expressions = <RegExp>[];
|
||||
|
||||
// adding the fallbacks
|
||||
// - match just *any* language
|
||||
// - match only unlocalized
|
||||
// - match the five mostly spoken languages of the world, copied from Wikipedia
|
||||
// - match just *any* language
|
||||
expressions.addAll(
|
||||
[
|
||||
RegExp(
|
||||
'^([a-z]+(-[a-z]+)?\\.lproj\\/)?$name(@\\d+x)?\\.$extension\$',
|
||||
'^[a-z]+(-[a-z]+)?\\.lproj\\/$name(@\\d+x)?\\.$extension\$',
|
||||
unicode: true,
|
||||
caseSensitive: false,
|
||||
),
|
||||
|
@ -44,6 +60,11 @@ abstract class FileMatcher {
|
|||
caseSensitive: false,
|
||||
),
|
||||
),
|
||||
RegExp(
|
||||
'^$name(@\\d+x)?\\.$extension\$',
|
||||
unicode: true,
|
||||
caseSensitive: false,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue