Skip to content

Commit

Permalink
chore(platform_interface): Added a warning for services name ending w…
Browse files Browse the repository at this point in the history
…ith a dot.
  • Loading branch information
Skyost committed Jan 27, 2024
1 parent 8caf1c7 commit 0a30efc
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:convert';

import 'package:flutter/foundation.dart';

/// Contains various methods that helps conforming to RFC 6335 and RFC 6763.
class BonsoirServiceNormalizer {
/// The default service name.
Expand All @@ -17,6 +19,15 @@ class BonsoirServiceNormalizer {
// Service names MUST NOT contain ASCII control characters (byte values 0x00-0x1F and 0x7F).
result.replaceAll(RegExp(r'[\x00-\x1F\x7F]'), '');

// On some platforms (eg. Windows), services name are not correctly handled if they're ending with a dot.
if (name.endsWith(name)) {
if (kDebugMode) {
print("It seems that you've provided a service name ending with a dot : $name.");
print("Note that it's not correctly handled on all platforms (eg. Windows).");
print('Please consider removing the trailing dot of your service name.');
}
}

return result.isEmpty ? defaultServiceName : result;
}

Expand Down

0 comments on commit 0a30efc

Please sign in to comment.