Skip to content

Instantly share code, notes, and snippets.

@k88hudson
Last active August 8, 2018 15:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k88hudson/13da1c9cd877320aaf46481fdde6f410 to your computer and use it in GitHub Desktop.
Save k88hudson/13da1c9cd877320aaf46481fdde6f410 to your computer and use it in GitHub Desktop.
Search Shortcuts Spec

List of Search Shortcuts

const SEARCH_SHORTCUTS = [
  {keyword: "@amazon", shortURL: "amazon", url: "https://amazon.com"},
  {keyword: "@google", shortURL: "google", url: "https://google.com"}
];

Matching Rules

Search shortcuts should be matched based on a given link's .hostname property, which represents a shortened form of the hostname without the TLD and proceeding www. (sorry, misleading name. See ShortURL.jsm.

e.g. for a link {url: "https://www.google.com/foo"} the hostname is google.

i.e. for the above SEARCH_SHORTCUTS, the check link.hostname === shortcut.shortURL is sufficient to check for a match.

Search ShortCut Link Type

The form of a shortcut link produced by TopSitesFeed, requires the following fields, where shortcut is a search shortcut from the above SEARCH_SHORTCUTS:

{
  searchTopSite: true,
  
  // This is needed in order for tippy top to return the correct URL
  // in TippyTopProvider.processSite, as well as for blocking
  url: shortcut.url,
  
  label: shortcut.keyword
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment