mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
closes #207 header suggestions sorted by relevance
This commit is contained in:
@ -1,9 +1,12 @@
|
||||
import '../consts.dart';
|
||||
|
||||
List<String> getHeaderSuggestions(String pattern) {
|
||||
return kHttpHeadersMap.keys
|
||||
.where(
|
||||
(element) => element.toLowerCase().contains(pattern.toLowerCase()),
|
||||
)
|
||||
var matches = kHttpHeadersMap.keys
|
||||
.map((item) => (item.toLowerCase().indexOf(pattern.toLowerCase()), item))
|
||||
.where((element) => element.$1 >= 0)
|
||||
.toList();
|
||||
|
||||
matches.sort((a, b) => a.$1.compareTo(b.$1));
|
||||
|
||||
return matches.map((item) => item.$2).toList();
|
||||
}
|
||||
|
Reference in New Issue
Block a user