Skip to content

Commit 2babbcd

Browse files
committed
feat: Handled special characters in query
1 parent bc2d558 commit 2babbcd

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

assets/js/coveo.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,27 @@ async function atomicCoveo() {
3939
await searchInterface.initialize({
4040
accessToken: token,
4141
organizationId: org_id,
42-
renewAccessToken: () => {},
42+
preprocessRequest: (request, clientOrigin, metadata) => {
43+
const body = JSON.parse(request.body);
44+
body.q = `<@- ${body.q} -@>`;
45+
request.body = JSON.stringify(body);
46+
47+
return request;
48+
},
4349
});
4450
searchInterface.executeFirstSearch();
4551
}
4652

4753
await searchInterfaceStandalone.initialize({
4854
accessToken: token,
4955
organizationId: org_id,
50-
renewAccessToken: () => {},
56+
preprocessRequest: (request, clientOrigin, metadata) => {
57+
const body = JSON.parse(request.body);
58+
body.q = `<@- ${body.q} -@>`;
59+
request.body = JSON.stringify(body);
60+
61+
return request;
62+
},
5163
});
5264
searchInterfaceStandalone.executeFirstSearch();
5365
}

0 commit comments

Comments
 (0)