Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: Make search engine favicon configurable #1657

Merged
merged 1 commit into from
Feb 11, 2022

Conversation

b0o
Copy link
Collaborator

@b0o b0o commented Feb 10, 2022

I really like the new Omnibar search engine icon feature!

One issue I had is that I have numerous search engines configured where the search_url does not match the site it's searching.

For example, I use a Google Custom Search engine to search the Arch Linux forums, where the search_url is https://cse.google.com/cse/publicurl?cx=xxxxx&q=. With the old behavior, the Omnibar showed a Google favicon, but I want it to show an Arch Linux favicon.

New Behavior

With this change, users calling addSearchAlias can directly specify the desired favicon via the favicon_url property of the new options argument. For example:

addSearchAlias(
  'af', 
  'Arch Linux Forums', 
  'https://cse.google.com/cse/publicurl?cx=xxxxx&q=', 
  's', 
  'https://www.googleapis.com/customsearch/v1?key=xxxxx&cx=xxxxx&q=',
  function(response) {
    // ...
  },
  { favicon_url: 'https://archlinux.org/favicon.ico' },
);

This is also useful when a site's favicon isn't accessible at the standard /favicon.ico path. For example, Dribbble's /favicon.ico returns a 404 error; the actual favicon URL is https://cdn.dribbble.com/assets/favicon-b38525134603b9513174ec887944bde1a869eb6cd414f4d640ee48ab2a15a26b.ico.

Finally, this makes it possible to use an image encoded in a data URI as a favicon, which is useful if you want to use a custom favicon that's not hosted on the web.

Implementation Notes

I added a new options argument to api.addSearchAlias() which accepts an object containing the favicon_url key. I took this approach rather than adding a single argument specifically for the new favicon_url option because the function signature was already getting very long. Accepting an options object will make it easier to add additional options in the future without making the signature even longer.

@brookhong brookhong merged commit 9dd3c50 into brookhong:master Feb 11, 2022
@brookhong
Copy link
Owner

Thanks a lot for the graceful improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants