Add a search_provider property to define space encoding and other transformations
Categories
(Firefox :: Search, enhancement, P5)
Tracking
()
People
(Reporter: aminomancer, Unassigned)
Details
I've been making search engine extensions recently, and mostly for websites that don't publish an OpenSearch description or are generally not designed with OpenSearch in mind. Sometimes the only thing that stops an engine extension from working as intended is just the website's chosen word delimiter. Some sites use space, some use + (plus), some use - (dash) or _ (underscore). And we don't currently have a way to turn a normal search string like "Hello world!" into that kind of string, e.g. hello-world or hello+world or hello_world
There is an encoding property that can define how the search terms are encoded as a whole, but ordinarily we just want to use UTF-8 with the sole exception that spaces be replaced by some particular character, which just depends on the website being searched.
I can imagine some other scenarios where other characters are represented in an unusual way. Spaces are definitely by far the most common, but if a new property was added to the schema to support searching less conventional sites, it wouldn't hurt to let the extension define a set of string replacement rules.
I've been trying to make a search engine for a site that excludes special characters from search strings, encodes spaces as dashes, and only allows lowercase strings. So rules for working around that could look something like this, if all of them were supported:
"term_replace": [
["/\s/g", "-"],
["/[A-Z]/g", "to_lowercase"],
["/\'/g", ""],
]
I think the lowercase one is probably the most problematic. It could be done by responding in a special way to a reserved word like to_lowercase or to_uppercase, or it could accept an object with a function string to pass to String.prototype.replace, like this:
"term_replace": [
["/\s/g", "-"],
{
"matches": "/[A-Z]/g",
"replace": "(x) => x.toLowerCase()",
},
["/\'/g", ""],
]
Anyway, I think the most commonly needed one is definitely the space encoding thing. That could be made simpler, of course. It could just be a space_character property that just accepts a string with which Firefox will replace spaces in the search terms.
Updated•3 years ago
|
Updated•3 years ago
|
Comment 1•3 years ago
|
||
This is not something we'd do in the extension framework but it would be something for the search team to consider how they might support this.
Comment 2•3 years ago
|
||
Hello! Thank you for submitting this issue, Mark can you take a look at this and eventually confirm this issue?
Comment 3•3 years ago
|
||
We think this is a reasonable request to implement.
We probably wouldn't do it for OpenSearch installed engines, since the spec doesn't support it, and isn't in active development at the moment. However, it does seem reasonable that we could think about this for WebExtensions, though we are unlikely to work on it in the short term.
Description
•