dmlls / yang

Yang! - Yet Another Bangs anywhere Firefox extension
https://addons.mozilla.org/addon/yang-addon/
GNU General Public License v3.0
13 stars 1 forks source link

Custom bangs behaves different from DuckDuckGo bangs #6

Closed alkorang closed 1 month ago

alkorang commented 1 month ago

I configured Yang custom bang !g {{{s}}} to open https://www.google.com/search?q={{{s}}}. I tried tests with and without URL Encode Query option.

The original DuckDuckGo bang! with an emtpy query directly opens the first page of the site. For example, !g with opens https://www.google.com. I guess it opens the link of "d" element from bang.js file when there is no keyword.

{"c":"Online Services","d":"www.google.com","r":2123537,"s":"Google","sc":"Google","t":"g","u":"https://www.google.com/search?q={{{s}}}"}

Yang! custom bang behaves differently. It opens https://www.google.com/search?q= page with an empty query. It has no option to configure the page to open with an empty query.

alkorang commented 1 month ago

DuckDuckGo bang escapes query properly, while Yang custom bang does not encode. For example, with !g A&B, DuckDuckGo bang opens https://www.google.com/search?hl=ko&q=A%26B and searches A&B properly. Yang custom bang opens https://www.google.com/search?q=A&B= and searches A omitting &B part.

Changing URL Encode Query option does not change the behavior of Yang custom bang. I guess one solution could be escaping & in the query variable in background.js.

dmlls commented 1 month ago

Hi @alkorang, thanks for your detailed reports.

While Yang! does not aim to mirror DuckDuckGo's behavior one-to-one, I believe your concerns are valid.


Yang! custom bang behaves differently. It opens https://www.google.com/search?q= page with an empty query. It has no option to configure the page to open with an empty query.

I'm already working on adding an option called "Open Base URL" (similar to what Kagi Search offers), that will just do that, open the base URL. E.g., if the URL was https://github.com/dmlls/yang/issues/6, with this option on and no query, https://github.com would be opened. If you still wanted to have a bang redirecting to the entire path, you could simply add a bang with the full URL (and no {{{s}}}) and the "Open Base URL" option unchecked.


DuckDuckGo bang escapes query properly, while Yang custom bang does not encode.

This must be a bug, will look into it!

dmlls commented 1 month ago

Hi @alkorang, the changes are live at https://addons.mozilla.org/addon/yang-addon/.

Please, give it a try and in case there's anything still broken, don't hesitate to open a new issue. Thanks! :)

alkorang commented 1 month ago

Hi @dmlls. Everything works perfectly for me. Thank you for the quick update!