Documentation
¶
Overview ¶
Package autocomplete provides domain types and logic for URL autocompletion.
Index ¶
- func BestURLCompletion(input string, urls []string) (suffix, matchedURL string, ok bool)
- func BestURLCompletionWithIndex(input string, urls []string) (suffix, matchedURL string, index int, ok bool)
- func ComputeCompletionSuffix(input, fullText string) (string, bool)
- func ComputeURLCompletionSuffix(input, fullURL string) (suffix, matchedURL string, ok bool)
- func StripProtocol(url string) string
- type Suggestion
- type SuggestionSource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BestURLCompletion ¶ added in v0.27.0
BestURLCompletion returns the best completion candidate from a list of URLs. For host-like queries (for example "goo"), it prefers short host completions over deep redirect paths.
func BestURLCompletionWithIndex ¶ added in v0.27.0
func BestURLCompletionWithIndex(input string, urls []string) (suffix, matchedURL string, index int, ok bool)
BestURLCompletionWithIndex returns the best completion candidate and its source URL index.
func ComputeCompletionSuffix ¶
ComputeCompletionSuffix returns the suffix if input is a case-insensitive prefix of fullText. Returns the suffix and true if input matches as a prefix, otherwise empty string and false.
func ComputeURLCompletionSuffix ¶
ComputeURLCompletionSuffix computes the completion suffix for URLs, handling protocol stripping for better matching. It tries matching with and without protocol prefixes.
func StripProtocol ¶
StripProtocol removes http:// or https:// prefix from a URL for matching.
Types ¶
type Suggestion ¶
type Suggestion struct {
FullText string // The complete text (URL or bang shortcut)
Suffix string // The suffix to append after the user's input
Source SuggestionSource // Where this suggestion came from
Title string // Display title (page title or description)
}
Suggestion represents a single autocomplete suggestion with its completion suffix.
type SuggestionSource ¶
type SuggestionSource int
SuggestionSource indicates the origin of an autocomplete suggestion.
const ( SourceHistory SuggestionSource = iota SourceFavorite SourceBangShortcut )