Dots in object key names are misrepresented and treated as nested values #432
Closed
Description
Describe the bug
If you want to search into nested objects, the keys of that object cannot contain dots, otherwise when specifying Fuse options they will be treated as nested values. In my case, every key is a url and the dots cannot be avoided.
Version
v6.0.2
Is this a regression?
No
🔬Minimal Reproduction
Have a list of objects such as:
[
{
id: 'http://xmlns.com/foaf/0.1/',
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type': [
{
type: 'uri',
value: 'http://www.w3.org/2002/07/owl#Ontology',
},
],
},
]
You want to search for value
inside http://www.w3.org/1999/02/22-rdf-syntax-ns#type
, so you define an options object:
const options = {
keys: ['id', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type.value'],
};
Since nested objects are indicated with a dot, Fuse treats e.g. w3
as a key contained in the object http://www
.
Additional context
It could be solved by using e.g. optional nested arrays for such values:
const options = {
keys: ['id', ['http://www.w3.org/1999/02/22-rdf-syntax-ns#type', 'value']],
};