Skip to content

Commit

Permalink
Added "noindex" header for robots
Browse files Browse the repository at this point in the history
  • Loading branch information
breitburg committed Nov 13, 2021
1 parent 3004420 commit 86177cc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions lib/core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,19 @@ class Shorter {
}

void process(HttpRequest request) {
database.search(request.uri.path).then((String? value) {
var redirectableUrl = value ?? '/';
database.search(request.uri.path).then(
(String? value) {
var redirectableUrl = value ?? '/';

print('Redirecting ${request.uri.path} to $redirectableUrl '
'from ${request.connectionInfo?.remoteAddress.address}');
print('Redirecting ${request.uri.path} to $redirectableUrl '
'from ${request.connectionInfo?.remoteAddress.address}');

request.response
..redirect(Uri.parse(redirectableUrl),
status: HttpStatus.permanentRedirect)
..close();
});
request.response
..headers.add('X-Robots-Tag', 'noindex')
..redirect(Uri.parse(redirectableUrl),
status: HttpStatus.permanentRedirect)
..close();
},
);
}
}
2 changes: 1 addition & 1 deletion lib/database/base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Database {
assert(interval.inSeconds >= 10);

scheduler = NeatPeriodicTaskScheduler(
name: 'Sync "$runtimeType" database',
name: 'Sync of "$runtimeType" database',
interval: interval,
timeout: const Duration(seconds: 5),
minCycle: const Duration(seconds: 5),
Expand Down

0 comments on commit 86177cc

Please sign in to comment.