@absolutejs/search 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/changelog.json +10 -0
- package/dist/brave.js +6 -4
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,12 @@ This file is generated by `absolute-changelog` from the entries in
|
|
|
6
6
|
`changelog/`. Edit an entry, not this file — and add new ones under
|
|
7
7
|
`changelog/unreleased/`.
|
|
8
8
|
|
|
9
|
+
## 0.2.1 — 2026-09-28
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
|
|
13
|
+
- **Brave web searches no longer fail with HTTP 404: the Api-Version header is sent only when a caller pins apiVersion, and a web search with no results is reported as empty instead of malformed.**
|
|
14
|
+
|
|
9
15
|
## 0.2.0 — 2026-09-24
|
|
10
16
|
|
|
11
17
|
### Added
|
package/changelog.json
CHANGED
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
"contract": 1,
|
|
3
3
|
"name": "@absolutejs/search",
|
|
4
4
|
"releases": [
|
|
5
|
+
{
|
|
6
|
+
"changes": [
|
|
7
|
+
{
|
|
8
|
+
"kind": "fixed",
|
|
9
|
+
"summary": "Brave web searches no longer fail with HTTP 404: the Api-Version header is sent only when a caller pins apiVersion, and a web search with no results is reported as empty instead of malformed."
|
|
10
|
+
}
|
|
11
|
+
],
|
|
12
|
+
"date": "2026-09-28",
|
|
13
|
+
"version": "0.2.1"
|
|
14
|
+
},
|
|
5
15
|
{
|
|
6
16
|
"changes": [
|
|
7
17
|
{
|
package/dist/brave.js
CHANGED
|
@@ -95,7 +95,7 @@ var braveSearchCapabilities = {
|
|
|
95
95
|
};
|
|
96
96
|
var createBraveSearch = (options) => {
|
|
97
97
|
const now = options.now ?? Date.now;
|
|
98
|
-
const version = options.apiVersion ?? "
|
|
98
|
+
const version = options.apiVersion ?? "default";
|
|
99
99
|
return {
|
|
100
100
|
name: "brave",
|
|
101
101
|
capabilities: braveSearchCapabilities,
|
|
@@ -156,7 +156,7 @@ var createBraveSearch = (options) => {
|
|
|
156
156
|
const headers = {
|
|
157
157
|
accept: "application/json",
|
|
158
158
|
"X-Subscription-Token": options.apiKey,
|
|
159
|
-
"Api-Version":
|
|
159
|
+
...options.apiVersion ? { "Api-Version": options.apiVersion } : {},
|
|
160
160
|
"Content-Type": "application/json"
|
|
161
161
|
};
|
|
162
162
|
const url = new URL(`https://api.search.brave.com${endpoint}`);
|
|
@@ -202,9 +202,11 @@ var createBraveSearch = (options) => {
|
|
|
202
202
|
if (!record(body))
|
|
203
203
|
throw new Error("Invalid Brave response");
|
|
204
204
|
const container = mode === "context" ? body.grounding : body.web;
|
|
205
|
-
|
|
205
|
+
const listed = record(container) ? container[mode === "context" ? "generic" : "results"] : undefined;
|
|
206
|
+
const noWebResults = mode === "web" && body.type === "search" && body.web === undefined;
|
|
207
|
+
if (!noWebResults && !Array.isArray(listed))
|
|
206
208
|
throw new Error("Brave response is missing its result array");
|
|
207
|
-
const rows =
|
|
209
|
+
const rows = Array.isArray(listed) ? listed : [];
|
|
208
210
|
let invalid = 0;
|
|
209
211
|
const byUrl = new Map;
|
|
210
212
|
for (const row of rows) {
|