autocomplete

package
v0.26.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 26, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package autocomplete provides domain types and logic for URL autocompletion.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeCompletionSuffix

func ComputeCompletionSuffix(input, fullText string) (string, bool)

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

func ComputeURLCompletionSuffix(input, fullURL string) (suffix, matchedURL string, ok bool)

ComputeURLCompletionSuffix computes the completion suffix for URLs, handling protocol stripping for better matching. It tries matching with and without protocol prefixes.

func StripProtocol

func StripProtocol(url string) string

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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL