Skip to content

Commit

Permalink
fix:regex pattern matches all route patterns
Browse files Browse the repository at this point in the history
  • Loading branch information
iyifr committed Aug 24, 2024
1 parent a29206d commit 2b5a4ba
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
4 changes: 0 additions & 4 deletions bin/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,4 @@ void main() async {
router.get("/hi", (event) {
throw CreateError(message: "HAHA");
});

router.get('#', (event) {
return 'Hi';
});
}
4 changes: 3 additions & 1 deletion lib/src/extract_path_pieces.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ bool isValidHttpPathPattern(String pattern) {
r'/'
r'|/(?:[\p{L}\p{N}_-]+(?:/[\p{L}\p{N}_-]+)*/?)'
r'|/(?:[\p{L}\p{N}_-]+(?:/[\p{L}\p{N}_-]+)*/)*:(?:[\p{L}\p{N}_]+)(?:/|$)'
r'|/[\p{L}\p{N}_-]+/:[^/]+/\*\*'
r'|/[\p{L}\p{N}_-]+/\*\*'
r'|/[\p{L}\p{N}_-]+/\*'
r'|\*'
r')$',
unicode: true,
);

return regex.hasMatch(pattern);
}
23 changes: 22 additions & 1 deletion lib/src/logger.dart
Original file line number Diff line number Diff line change
@@ -1,10 +1,31 @@
import 'package:logging/logging.dart';
import 'package:console/console.dart';

var logger = Logger('H4');

initLogger() {
Logger.root.level = Level.ALL; // defaults to Level.INFO
Logger.root.onRecord.listen((record) {
print('${record.level.name}: ${record.message}');
switch (record.level.name) {
case 'INFO':
{
Console.setBackgroundColor(6, bright: true);
Console.setTextColor(2, bright: true);
// ignore: unnecessary_string_escapes
Console.write('\n ${record.level.name} ');
Console.resetBackgroundColor();
Console.resetTextColor();
Console.setBold(false);
Console.write(' ▲▼▲▼▲▼ ${record.message}\n');
Console.resetAll();
}

case 'SEVERE':
{
Console.setFramed(true);
Console.write(record.level.name);
Console.write(record.message);
}
}
});
}

0 comments on commit 2b5a4ba

Please sign in to comment.