Compare commits

...

2 commits
1.2.0 ... main

Author SHA1 Message Date
qf3l3k
e1ef155df4 release: 1.2.1 2026-05-20 17:47:34 +02:00
qf3l3k
ac1e6e239a fix: improve mobile REST response parsing 2026-05-20 17:41:54 +02:00
6 changed files with 46 additions and 11 deletions

View file

@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
## [1.2.1] - 2026-05-20
### Fixed
- Improved REST response parsing for mobile platforms by handling `Content-Type` headers case-insensitively and falling back to JSON body parsing when the payload is JSON-like. This fixes `path` lookups such as `path: 0` failing on Android and iPad for endpoints that return JSON arrays.
## [1.2.0] - 2026-05-02
### Added

View file

@ -1,7 +1,7 @@
{
"id": "data-fetcher",
"name": "Data Fetcher",
"version": "1.2.0",
"version": "1.2.1",
"minAppVersion": "1.8.3",
"description": "Fetch data from multiple sources (REST APIs, RPC, gRPC, GraphQL) and insert results into notes",
"author": "qf3l3k",

4
package-lock.json generated
View file

@ -1,12 +1,12 @@
{
"name": "obsidian-api-fetcher",
"version": "1.2.0",
"version": "1.2.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "obsidian-api-fetcher",
"version": "1.2.0",
"version": "1.2.1",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.11.6",

View file

@ -1,6 +1,6 @@
{
"name": "obsidian-api-fetcher",
"version": "1.2.0",
"version": "1.2.1",
"description": "Fetch data from multiple sources (REST APIs, RPC, gRPC, GraphQL) and insert results into notes",
"main": "main.js",
"scripts": {

View file

@ -23,6 +23,32 @@ export interface QueryResult {
error?: string;
}
function findHeaderValue(headers: Record<string, string>, targetName: string): string | undefined {
const normalizedTarget = targetName.toLowerCase();
for (const [name, value] of Object.entries(headers || {})) {
if (name.toLowerCase() === normalizedTarget) {
return value;
}
}
return undefined;
}
function tryParseJsonText(text: string): any | undefined {
const trimmed = text.trim();
if (!trimmed.startsWith('{') && !trimmed.startsWith('[')) {
return undefined;
}
try {
return JSON.parse(trimmed);
} catch {
return undefined;
}
}
function formatRequestError(error: unknown): string {
const message = error instanceof Error ? error.message : String(error);
const normalized = message.toLowerCase();
@ -291,14 +317,17 @@ async function executeRestQuery(params: QueryParams): Promise<any> {
const response = await requestUrl(requestParams);
// Parse response based on content type
const contentType = response.headers['content-type'];
if (contentType && contentType.includes('application/json')) {
// Mobile builds may expose response headers with different casing, so
// treat Content-Type lookup as case-insensitive and fall back to parsing
// the body when JSON-looking payloads arrive without a usable header.
const contentType = findHeaderValue(response.headers || {}, 'content-type');
if (contentType && contentType.toLowerCase().includes('application/json')) {
return response.json;
} else {
return response.text;
}
const parsedText = tryParseJsonText(response.text);
return parsedText !== undefined ? parsedText : response.text;
}
/**

View file

@ -10,5 +10,6 @@
"1.1.3": "1.8.3",
"1.1.4": "1.8.3",
"1.1.5": "1.8.3",
"1.2.0": "1.8.3"
"1.2.0": "1.8.3",
"1.2.1": "1.8.3"
}